Possibly unitialized used of variable
Hi all, GCC 4.6.1 gives an uninit var warning in sp-canvas.cpp:
src/2geom/generic-interval.h: In static member function 'static void SPCanvasGroup::update(SPCanvasItem*, const Geom::Affine&, unsigned int)':
src/2geom/generic-interval.h:144:8: error: '*((void*)(& bounds)+24).Geom::GenericInterval<double>::_b[1]' may be used uninitialized in this function [-Werror=uninitialized]
src/display/sp-canvas.cpp:1051:19: note: '*((void*)(& bounds)+24).Geom::GenericInterval<double>::_b[1]' was declared here
...
I have been working on this warning for hours, but I cannot find the problem. Because I have already found a (serious) bug from another warning like this, I am very reluctant to conclude that it is a compiler mis-analysis.
I would greatly appreciate someone else having a (thorough) look at this.
Thanks, Johan
Hi, neither gcc 4.8.1 nor clang 3.4 nor msvc 12 produce this warning, so I think this might be a false positive that has been fixed in newer compiler versions. I don't see how _b[1] could be not initialized...
Here's the warning I currently like best: ../../trunk/src/gradient-drag.cpp:2390:69: warning: variable 'p' is uninitialized when used within its own initialization [-Wuninitialized] Geom::Point p = ls.pointAt(ls.nearestPoint(dragger->point + p));
Regards, Markus
-----Ursprüngliche Nachricht----- Von: Johan Engelen [mailto:jbc.engelen@...2592...] Gesendet: Sonntag, 23. März 2014 13:24 An: Inkscape-Devel Betreff: [Inkscape-devel] Possibly unitialized used of variable
Hi all, GCC 4.6.1 gives an uninit var warning in sp-canvas.cpp:
src/2geom/generic-interval.h: In static member function 'static void SPCanvasGroup::update(SPCanvasItem*, const Geom::Affine&, unsigned int)':
src/2geom/generic-interval.h:144:8: error: '*((void*)(& bounds)+24).Geom::GenericInterval<double>::_b[1]' may be used uninitialized in this function [-Werror=uninitialized]
src/display/sp-canvas.cpp:1051:19: note: '*((void*)(& bounds)+24).Geom::GenericInterval<double>::_b[1]' was declared here
...
I have been working on this warning for hours, but I cannot find the problem. Because I have already found a (serious) bug from another warning like this, I am very reluctant to conclude that it is a compiler mis-analysis.
I would greatly appreciate someone else having a (thorough) look at this.
Thanks, Johan
---------------------------------------------------------------------------- -- Learn Graph Databases - Download FREE O'Reilly Book "Graph Databases" is the definitive new guide to graph databases and their applications. Written by three acclaimed leaders in the field, this first edition is now available. Download your free book today! http://p.sf.net/sfu/13534_NeoTech _______________________________________________ Inkscape-devel mailing list Inkscape-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/inkscape-devel
On 23-3-2014 14:05, Markus Engel wrote:
Hi, neither gcc 4.8.1 nor clang 3.4 nor msvc 12 produce this warning, so I think this might be a false positive that has been fixed in newer compiler versions. I don't see how _b[1] could be not initialized...
Thanks for checking with newer compilers.
Here's the warning I currently like best: ../../trunk/src/gradient-drag.cpp:2390:69: warning: variable 'p' is uninitialized when used within its own initialization [-Wuninitialized] Geom::Point p = ls.pointAt(ls.nearestPoint(dragger->point + p));
My goodness, what a terrible bug. Fixed in rev. 13186.
Does everybody now see why warnings are important?! Yes newer compilers may throw more warnings, but they are *better* warnings and we *need* to error on them, *by default*.
Thanks, Johan
:) Actually, clang has already output this warning a year ago, but I never managed to look into this... gcc did never complain. You should probably get a few different environments (clang with -Weverything ;)) so you can fix even more warnings...
In many places I'm just not sure whether these things are intended. Let's say ../../trunk/src/live_effects/lpe-powerstroke.cpp:611:104: warning: implicit conversion from 'double' to 'bool' changes value from 0.01 to false [-Wliteral-conversion] Geom::Path fixed_path = path_from_piecewise_fix_cusps( pwd2_out, y, jointype, miter_limit, LPE_CONVERSION_TOLERANCE);
#define LPE_CONVERSION_TOLERANCE 0.01 // FIXME: find good solution for this.
The last parameter is a bool though. So?
Regards, Markus
-----Ursprüngliche Nachricht----- Von: Johan Engelen [mailto:jbc.engelen@...2592...] Gesendet: Sonntag, 23. März 2014 14:42 An: Markus Engel; 'Inkscape-Devel' Betreff: Re: AW: [Inkscape-devel] Possibly unitialized used of variable
On 23-3-2014 14:05, Markus Engel wrote:
Hi, neither gcc 4.8.1 nor clang 3.4 nor msvc 12 produce this warning, so I think this might be a false positive that has been fixed in newer compiler versions. I don't see how _b[1] could be not initialized...
Thanks for checking with newer compilers.
Here's the warning I currently like best: ../../trunk/src/gradient-drag.cpp:2390:69: warning: variable 'p' is uninitialized when used within its own initialization [-Wuninitialized] Geom::Point p = ls.pointAt(ls.nearestPoint(dragger->point + p));
My goodness, what a terrible bug. Fixed in rev. 13186.
Does everybody now see why warnings are important?! Yes newer compilers may throw more warnings, but they are *better* warnings and we *need* to error on them, *by default*.
Thanks, Johan
On 23-3-2014 14:51, Markus Engel wrote:
:) Actually, clang has already output this warning a year ago, but I never managed to look into this... gcc did never complain. You should probably get a few different environments (clang with -Weverything ;)) so you can fix even more warnings...
I so desperately want to build with clang on Windows... :'( :'( :'(
In many places I'm just not sure whether these things are intended. Let's say ../../trunk/src/live_effects/lpe-powerstroke.cpp:611:104: warning: implicit conversion from 'double' to 'bool' changes value from 0.01 to false [-Wliteral-conversion] Geom::Path fixed_path = path_from_piecewise_fix_cusps( pwd2_out, y, jointype, miter_limit, LPE_CONVERSION_TOLERANCE);
#define LPE_CONVERSION_TOLERANCE 0.01 // FIXME: find good solution for this.
The last parameter is a bool though. So?
Again you found a terrible bug! I know my powerstroke code needs a LOT of love, but this is really a bad coding bug. The bug here was that the caller things it is setting the tolerance but instead it is setting a bool parameter that is unused, and the conversion tolerance is set to the default value.
See the fix in rev. 13188.
So this was not a false positive at all.
ciao, Johan
Why don't you use a vm? Later we should make sure that we let configure automatically choose warning options depending on the used compiler: warning: unknown warning option '-Wno-unused-but-set-variable'; did you mean '-Wno-unused-variable'? [-Wunknown-warning-option]
../../trunk/src/gradient-drag.cpp:1491:26: warning: comparison of constant -1 with expression of type 'GrPointType' is always false [-Wtautological-constant-out-of-range-compare] (point_type == -1 || da->point_type == point_type) && ----- ../../trunk/src/extension/internal/emf-print.cpp:948:49: warning: variable 'i' is uninitialized when used here [-Wuninitialized] for(int i; cit != pathRect.end_open();++cit,i++) { ^ ../../trunk/src/extension/internal/emf-print.cpp:948:14: note: initialize the variable 'i' to silence this warning for(int i; cit != pathRect.end_open();++cit,i++) { ^ = 0
I could provide you with a list of warnings emitted by clang, if you want me to :) .
Regards, Markus
-----Ursprüngliche Nachricht----- Von: Johan Engelen [mailto:jbc.engelen@...2592...] Gesendet: Sonntag, 23. März 2014 15:07 An: Markus Engel; 'Inkscape-Devel' Betreff: Re: AW: AW: [Inkscape-devel] Possibly unitialized used of variable
On 23-3-2014 14:51, Markus Engel wrote:
:) Actually, clang has already output this warning a year ago, but I never managed to look into this... gcc did never complain. You should probably get a few different environments (clang with -Weverything ;)) so you can fix even more warnings...
I so desperately want to build with clang on Windows... :'( :'( :'(
In many places I'm just not sure whether these things are intended. Let's say ../../trunk/src/live_effects/lpe-powerstroke.cpp:611:104: warning: implicit conversion from 'double' to 'bool' changes value from 0.01 to
false
[-Wliteral-conversion] Geom::Path fixed_path = path_from_piecewise_fix_cusps(
pwd2_out,
y, jointype, miter_limit, LPE_CONVERSION_TOLERANCE);
#define LPE_CONVERSION_TOLERANCE 0.01 // FIXME: find good solution for this.
The last parameter is a bool though. So?
Again you found a terrible bug! I know my powerstroke code needs a LOT of love, but this is really a bad coding bug. The bug here was that the caller things it is setting the tolerance but instead it is setting a bool parameter that is unused, and the conversion tolerance is set to the default value.
See the fix in rev. 13188.
So this was not a false positive at all.
ciao, Johan
On 23-3-2014 15:17, Markus Engel wrote:
Why don't you use a vm?
Ease of use / laziness. It would help if I could share diskspace from host to VM, so only the compilation is done on the VM, but I still have the file handling / bzr / etc. from Windows. Haven't looked into how to do that. We will change compiler anyway on Windows after the release, to switch to C++11. We could then choose a compiler with clang compatible EH for the devlibs. I look forward to playing with clang's static and dynamic analyzers. Anybody using those yet? clang's refactoring tools,... *sigh*
Later we should make sure that we let configure automatically choose warning options depending on the used compiler: warning: unknown warning option '-Wno-unused-but-set-variable'; did you mean '-Wno-unused-variable'? [-Wunknown-warning-option]
../../trunk/src/gradient-drag.cpp:1491:26: warning: comparison of constant -1 with expression of type 'GrPointType' is always false [-Wtautological-constant-out-of-range-compare] (point_type == -1 || da->point_type == point_type) &&
Definitely a bug waiting to happen (if not already).
../../trunk/src/extension/internal/emf-print.cpp:948:49: warning: variable 'i' is uninitialized when used here [-Wuninitialized] for(int i; cit != pathRect.end_open();++cit,i++) { ^ ../../trunk/src/extension/internal/emf-print.cpp:948:14: note: initialize the variable 'i' to silence this warning for(int i; cit != pathRect.end_open();++cit,i++) { ^ = 0
:'(
I could provide you with a list of warnings emitted by clang, if you want me to :) .
Please send it to the list. To further drill on people's heads to look at warnings and enable -Werror. Can I move you to provide some fixes for those too? :-)
Thanks a lot, Johan
Ease of use / laziness. It would help if I could share diskspace from host to VM, so only the compilation is done on the VM, but I still have the file handling / bzr / etc. from Windows. Haven't looked into how to do that.
Use Vagrant. (http://www.vagrantup.com/)
I tried it out with Inkscape in January primarily for GUI testing but it's a better fit for your compilation problem [1]. Your exact use case is what I use during my master thesis project. I develop Internet of Things related software in Ada (on my host) and let a VM (Virtualbox) be the build machine. This allows me to separate specific build tools to the VM with ease. The Vagrant settings allows you to map host-folders to VM-folders in a one line configuration.
I haven't tried Windows as host or guest yet though but could be interesting to try out.
[1] https://code.launchpad.net/~inkscape.dev/inkscape/vagrant-no-desktop
Regards
But you *can* share diskspace. Simply add your source directory as a "shared folder" in VirtualBox or VMware Player and choose "auto mount" and "make permanent". You can then access your data via /media/sf_<...>. I tried the static analyzer, I will append a log file later. The dynamic analyzer will produce lots of warnings because of libgc I'm afraid, but I'll give it a try. In another project I use it like this: "-fsanitize=address,undefined,alignment,bool,bounds,enum,null,return,unreach able,vptr"
This is an example output when starting the program: /usr/include/luabind/detail/constructor.hpp:93:26: runtime error: member call on misaligned address 0x60b00000ada8 for type 'luabind::detail::object_rep', which requires 16 byte alignment 0x60b00000ada8: note: pointer points here 00 00 00 00 00 00 00 00 00 00 00 00 be be be be be be be be be be be be be be be be be be be be ^
Here's the list of warnings: https://db.tt/s0Nf2S3N
Regards, Markus
-----Ursprüngliche Nachricht----- Von: Johan Engelen [mailto:jbc.engelen@...2592...] Gesendet: Sonntag, 23. März 2014 16:54 An: Markus Engel; 'Inkscape-Devel' Betreff: Re: AW: AW: AW: [Inkscape-devel] Possibly unitialized used of variable
On 23-3-2014 15:17, Markus Engel wrote:
Why don't you use a vm?
Ease of use / laziness. It would help if I could share diskspace from host to VM, so only the compilation is done on the VM, but I still have the file handling / bzr / etc. from Windows. Haven't looked into how to do that. We will change compiler anyway on Windows after the release, to switch to C++11. We could then choose a compiler with clang compatible EH for the devlibs. I look forward to playing with clang's static and dynamic analyzers. Anybody using those yet? clang's refactoring tools,... *sigh*
Later we should make sure that we let configure automatically choose warning options depending on the used compiler: warning: unknown warning option '-Wno-unused-but-set-variable'; did you mean '-Wno-unused-variable'? [-Wunknown-warning-option]
../../trunk/src/gradient-drag.cpp:1491:26: warning: comparison of constant -1 with expression of type 'GrPointType' is always false [-Wtautological-constant-out-of-range-compare] (point_type == -1 || da->point_type == point_type) &&
Definitely a bug waiting to happen (if not already).
../../trunk/src/extension/internal/emf-print.cpp:948:49: warning: variable 'i' is uninitialized when used here [-Wuninitialized] for(int i; cit != pathRect.end_open();++cit,i++) { ^ ../../trunk/src/extension/internal/emf-print.cpp:948:14: note: initialize the variable 'i' to silence this warning for(int i; cit != pathRect.end_open();++cit,i++) { ^ = 0
:'(
I could provide you with a list of warnings emitted by clang, if you want me to :) .
Please send it to the list. To further drill on people's heads to look at warnings and enable -Werror. Can I move you to provide some fixes for those too? :-)
Thanks a lot, Johan
The buildbots on Ubuntu produce a warning (e.g. Saucy, GCC 4.8.2) https://launchpadlibrarian.net/170132517/buildlog_ubuntu-saucy-amd64.inkscape-trunk_1%3A0.48%2Bdevel%2B13168%2B47~ubuntu13.10.1_UPLOADING.txt.gz
In file included from ../../src/2geom/interval.h:45:0, from ../../src/2geom/rect.h:45, from ../../src/display/sp-canvas.cpp:26: ../../src/2geom/generic-interval.h: In static member function 'static void SPCanvasGroup::update(SPCanvasItem*, const Geom::Affine&, unsigned int)': ../../src/2geom/generic-interval.h:144:8: warning: '*((void*)(& bounds)+24).Geom::GenericInterval<double>::_b[1]' may be used uninitialized in this function [-Wmaybe-uninitialized] if(val > _b[1]) _b[1] = val; //no else, as we want to handle NaN ^ ../../src/display/sp-canvas.cpp:1051:19: note: '*((void*)(& bounds)+24).Geom::GenericInterval<double>::_b[1]' was declared here Geom::OptRect bounds; ^ In file included from ../../src/2geom/interval.h:45:0, from ../../src/2geom/rect.h:45, from ../../src/display/sp-canvas.cpp:26: ../../src/2geom/generic-interval.h:143:8: warning: '*((void*)(& bounds)+24).Geom::GenericInterval<double>::_b[0]' may be used uninitialized in this function [-Wmaybe-uninitialized] if(val < _b[0]) _b[0] = val; ^ ../../src/display/sp-canvas.cpp:1051:19: note: '*((void*)(& bounds)+24).Geom::GenericInterval<double>::_b[0]' was declared here Geom::OptRect bounds; ^ In file included from ../../src/2geom/interval.h:45:0, from ../../src/2geom/rect.h:45, from ../../src/display/sp-canvas.cpp:26: ../../src/2geom/generic-interval.h:144:8: warning: '*((void*)(& bounds)+8).Geom::GenericInterval<double>::_b[1]' may be used uninitialized in this function [-Wmaybe-uninitialized] if(val > _b[1]) _b[1] = val; //no else, as we want to handle NaN ^ ../../src/display/sp-canvas.cpp:1051:19: note: '*((void*)(& bounds)+8).Geom::GenericInterval<double>::_b[1]' was declared here Geom::OptRect bounds; ^ In file included from ../../src/2geom/interval.h:45:0, from ../../src/2geom/rect.h:45, from ../../src/display/sp-canvas.cpp:26: ../../src/2geom/generic-interval.h:143:8: warning: '*((void*)(& bounds)+8).Geom::GenericInterval<double>::_b[0]' may be used uninitialized in this function [-Wmaybe-uninitialized] if(val < _b[0]) _b[0] = val; ^ ../../src/display/sp-canvas.cpp:1051:19: note: '*((void*)(& bounds)+8).Geom::GenericInterval<double>::_b[0]' was declared here Geom::OptRect bounds; ^
On 2014-03-23 14:05 +0100, Markus Engel wrote:
Hi, neither gcc 4.8.1 nor clang 3.4 nor msvc 12 produce this warning, so I think this might be a false positive that has been fixed in newer compiler versions. I don't see how _b[1] could be not initialized...
Here's the warning I currently like best: ../../trunk/src/gradient-drag.cpp:2390:69: warning: variable 'p' is uninitialized when used within its own initialization [-Wuninitialized] Geom::Point p = ls.pointAt(ls.nearestPoint(dragger->point + p));
Regards, Markus
-----Ursprüngliche Nachricht----- Von: Johan Engelen [mailto:jbc.engelen@...2592...] Gesendet: Sonntag, 23. März 2014 13:24 An: Inkscape-Devel Betreff: [Inkscape-devel] Possibly unitialized used of variable
Hi all, GCC 4.6.1 gives an uninit var warning in sp-canvas.cpp:
src/2geom/generic-interval.h: In static member function 'static void SPCanvasGroup::update(SPCanvasItem*, const Geom::Affine&, unsigned int)':
src/2geom/generic-interval.h:144:8: error: '*((void*)(& bounds)+24).Geom::GenericInterval<double>::_b[1]' may be used uninitialized in this function [-Werror=uninitialized]
src/display/sp-canvas.cpp:1051:19: note: '*((void*)(& bounds)+24).Geom::GenericInterval<double>::_b[1]' was declared here
...
I have been working on this warning for hours, but I cannot find the problem. Because I have already found a (serious) bug from another warning like this, I am very reluctant to conclude that it is a compiler mis-analysis.
I would greatly appreciate someone else having a (thorough) look at this.
Thanks, Johan
-- Learn Graph Databases - Download FREE O'Reilly Book "Graph Databases" is the definitive new guide to graph databases and their applications. Written by three acclaimed leaders in the field, this first edition is now available. Download your free book today! http://p.sf.net/sfu/13534_NeoTech _______________________________________________ Inkscape-devel mailing list Inkscape-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/inkscape-devel
Learn Graph Databases - Download FREE O'Reilly Book "Graph Databases" is the definitive new guide to graph databases and their applications. Written by three acclaimed leaders in the field, this first edition is now available. Download your free book today! http://p.sf.net/sfu/13534_NeoTech _______________________________________________ Inkscape-devel mailing list Inkscape-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/inkscape-devel
On Sun, Mar 23, 2014 at 01:23:33PM +0100, Johan Engelen wrote:
Hi all, GCC 4.6.1 gives an uninit var warning in sp-canvas.cpp:
src/2geom/generic-interval.h: In static member function 'static void SPCanvasGroup::update(SPCanvasItem*, const Geom::Affine&, unsigned int)':
src/2geom/generic-interval.h:144:8: error: '*((void*)(& bounds)+24).Geom::GenericInterval<double>::_b[1]' may be used uninitialized in this function [-Werror=uninitialized]
src/display/sp-canvas.cpp:1051:19: note: '*((void*)(& bounds)+24).Geom::GenericInterval<double>::_b[1]' was declared here
...
I have been working on this warning for hours, but I cannot find the problem. Because I have already found a (serious) bug from another warning like this, I am very reluctant to conclude that it is a compiler mis-analysis.
I would greatly appreciate someone else having a (thorough) look at this.
Thanks, Johan
Is it just complaining that the array is being initialized in the constructor body rather than set as defaults?
GenericInterval() { _b[0] = 0; _b[1] = 0; }
I.e. it's expecting:
GenericInterval() : _b[0](0), _b[1](0) { }
but you can't initialize array members via defaults.
http://stackoverflow.com/questions/2409819/c-constructor-initializer-for-arr...
If that's the case, not sure how to solve that, other than perhaps not using an array for this class?
Bryce
participants (5)
-
Bryce Harrington
-
Christoffer Holmstedt
-
Johan Engelen
-
Markus Engel
-
su_v