[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gnash-dev] [patch] Get rid of warning in LineStyle.cpp
From: |
Petter Reinholdtsen |
Subject: |
[Gnash-dev] [patch] Get rid of warning in LineStyle.cpp |
Date: |
Sun, 21 Nov 2010 22:00:54 +0100 |
User-agent: |
Mutt/1.4.2.2i |
I had a look at these warnings during build:
CXX LineStyle.lo
FillStyle.h: In member function 'void gnash::LineStyle::read(gnash::SWFStream&,
gnash::SWF::TagType, gnash::movie_definition&, const gnash::RunResources&)':
FillStyle.h:263: warning: dereferencing pointer '<anonymous>' does break
strict-aliasing rules
/usr/include/boost/variant/detail/cast_storage.hpp:33: note: initialized from
here
FillStyle.h: In member function 'void
gnash::LineStyle::read_morph(gnash::SWFStream&, gnash::SWF::TagType,
gnash::movie_definition&, const gnash::RunResources&, gnash::LineStyle*)':
FillStyle.h:263: warning: dereferencing pointer '<anonymous>' does break
strict-aliasing rules
/usr/include/boost/variant/detail/cast_storage.hpp:33: note: initialized from
here
FillStyle.h:263: warning: dereferencing pointer '<anonymous>' does break
strict-aliasing rules
/usr/include/boost/variant/detail/cast_storage.hpp:33: note: initialized from
here
I'm not sure I fully understand what is going on here, but I believe
it is related to implicit conversions and temp objects created when
returning the _color object.
This patch got rid of the warnings:
diff --git a/libcore/FillStyle.h b/libcore/FillStyle.h
index 927a3c7..3b39f85 100644
--- a/libcore/FillStyle.h
+++ b/libcore/FillStyle.h
@@ -259,7 +259,7 @@ public:
}
/// Get the color of the fill.
- rgba color() const {
+ const rgba& color() const {
return _color;
}
diff --git a/libcore/LineStyle.cpp b/libcore/LineStyle.cpp
index 12365fa..1d3d210 100644
--- a/libcore/LineStyle.cpp
+++ b/libcore/LineStyle.cpp
@@ -40,7 +40,7 @@ namespace {
class GetColor : public boost::static_visitor<rgba>
{
public:
- rgba operator()(const SolidFill& f) const {
+ const rgba& operator()(const SolidFill& f) const {
return f.color();
}
rgba operator()(const GradientFill&) const {
The change remove the need for some of the temporary objects that need
to be created and copied around when rgba.color() is used by GetColor,
and I believe it is good coding style to avoid forcing the compiler to
create more object that necessary.
Is this the correct fix? Anyone understand why it is needed?
Happy hacking,
--
Petter Reinholdtsen
- [Gnash-dev] [patch] Get rid of warning in LineStyle.cpp,
Petter Reinholdtsen <=