OpenSceneGraph Forum Forum Index OpenSceneGraph Forum
Official forum which mirrors the existent OSG mailing lists. Messages posted here are forwarded to the mailing list and vice versa.
 
   FAQFAQ    SearchSearch    MemberlistMemberlist    RulesRules    UsergroupsUsergroups    RegisterRegister 
 Mail2Forum SettingsMail2Forum Settings  ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
   AlbumAlbum  OpenSceneGraph IRC ChatOpenSceneGraph IRC Chat   SmartFeedSmartFeed 

x86_64, cmd line, built OK - but warning in Xcode


 
Post new topic   Reply to topic    OpenSceneGraph Forum Forum Index -> Build system [build]
View previous topic :: View next topic  
Author Message
scornflake
User


Joined: 09 Dec 2009
Posts: 25

PostPosted: Sun Apr 29, 2012 2:05 am    Post subject:
x86_64, cmd line, built OK - but warning in Xcode
Reply with quote

Hi,

I've successfully compiled trunk using cmake on 10.7.3. That's with Apple LLVM 3.0.0. No additional CXX flags passed into make.

With the "implicit conversion to 32bit type" enabled, I am seeing warnings to do with precision loss. e.g:

In file included from ../iShowU-v3/Frameworks/OpenSceneGraph-3.1.3/Debug/osg.framework/Headers/StateAttribute:20:
...
...
../Frameworks/OpenSceneGraph-3.1.3/Debug/osg.framework/Headers/Shader:56:47:{56:47-56:59}{56:40-56:46}: warning: implicit conversion loses integer precision: 'size_type' (aka 'unsigned long') to 'unsigned int' [-Wshorten-64-to-32,3]
unsigned int getSize() const { return _data.size(); }
~~~~~~ ^~~~~~~~~~~~

Couldn't get the formatting to work, but the ^ char is pointing at the _data term, just after return.


Is this something I need to be worried about? Is it safe for me to switch the warning off?
After looking - this warning appears to be disabled in my other projects - but it did get me a little concerned - so here I am, asking the Q. Smile


Thank you!
Neil
Back to top
View user's profile Send private message Visit poster's website
robertosfield
OSG Project Lead


Joined: 18 Mar 2009
Posts: 10908

PostPosted: Mon Apr 30, 2012 2:56 pm    Post subject:
x86_64, cmd line, built OK - but warning in Xcode
Reply with quote

Hi Neil,

This particular warning is benign - the data.size() will never be big
enough to be larger than a unit so the implicit cast is perfectly
safe.

Robert.

On 29 April 2012 03:05, Neil Clayton <> wrote:
Quote:
Hi,

I've successfully compiled trunk using cmake on 10.7.3. That's with Apple LLVM 3.0.0. No additional CXX flags passed into make.

With the "implicit conversion to 32bit type" enabled, I am seeing warnings to do with precision loss.  e.g:

In file included from ../iShowU-v3/Frameworks/OpenSceneGraph-3.1.3/Debug/osg.framework/Headers/StateAttribute:20:
...
...
../Frameworks/OpenSceneGraph-3.1.3/Debug/osg.framework/Headers/Shader:56:47:{56:47-56:59}{56:40-56:46}: warning: implicit conversion loses integer precision: 'size_type' (aka 'unsigned long') to 'unsigned int' [-Wshorten-64-to-32,3]
        unsigned int getSize() const { return _data.size(); }
                                       ~~~~~~ ^~~~~~~~~~~~

Couldn't get the formatting to work, but the ^ char is pointing at the _data term, just after return.


Is this something I need to be worried about?  Is it safe for me to switch the warning off?
After looking - this warning appears to be disabled in my other projects - but it did get me a little concerned - so here I am, asking the Q. :)


Thank you!
Neil

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=47399#47399








------------------
Post generated by Mail2Forum
Back to top
View user's profile Send private message
hartwigw
User


Joined: 20 Mar 2009
Posts: 86

PostPosted: Thu Dec 29, 2016 9:36 pm    Post subject:
Reply with quote

Hi,

I know that these compiler warnings are not critical but I find them still annoying and I think it is also not a good programming style to use the "wrong" integer type.

I also know that a simple modification might break some code (especially for virtual methods). But wouldn't it be in general a good idea to replace the mostly "unsigned int" types with size_t? Especially in constructors where very often a size is passed size_t can be used without problems (all STL size() methods return size_t types as a default type).

Cheers,
Hartwig
Back to top
View user's profile Send private message
robertosfield
OSG Project Lead


Joined: 18 Mar 2009
Posts: 10908

PostPosted: Thu Jan 05, 2017 9:55 am    Post subject:
x86_64, cmd line, built OK - but warning in Xcode
Reply with quote

Hi Hartwig,

If I were starting from scratch on a new project I would opt for
different types in certain places in the OSG, for the current version
of the OSG we need to be careful about changes that break ABI, or
provide any risk of errors being made during changes. Warnings on
certain build platforms might be slightly annoying for some users, but
bugs and build breaks are major stumbling blocks for everyone - the
later is what I use a metric for software quality not cosmetic changes
to quiet benign warnings.

Robert.

On 29 December 2016 at 21:36, Hartwig Wiesmann
<> wrote:
Quote:
Hi,

I know that these compiler warnings are not critical but I find them still annoying and I think it is also not a good programming style to use the "wrong" integer type.

I also know that a simple modification might break some code (especially for virtual methods). But wouldn't it be in general a good idea to replace the mostly "unsigned int" types with size_t? Especially in constructors where very often a size is passed size_t can be used without problems (all STL size() methods return size_t types as a default type).

Cheers,
Hartwig

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=69802#69802








------------------
Post generated by Mail2Forum
Back to top
View user's profile Send private message
hartwigw
User


Joined: 20 Mar 2009
Posts: 86

PostPosted: Thu Jan 05, 2017 6:09 pm    Post subject:
Reply with quote

Hi Robert,

I fully agree with you!
But would you mind if I submit patches that at least remove some warnings of existing code by adding an appropriate cast (the code with and without the cast should be identical)? I am especially concerned about header files because then the warnings are also polluting my code (and there might be some bugs).

Example (taken from osg::Drawable):

Code:
        virtual void apply(const ByteArray& array) {  if (!array.empty()) _af.apply(_type,array.size(),&(array.front())); }


should be replaced by

Code:
        virtual void apply(const ByteArray& array) {  if (!array.empty()) _af.apply(_type,static_cast<unsigned int>(array.size()),&(array.front())); }


Doing this kind of modification in osg::Drawable alone will remove about 30 to 40 warnings already!

Thank you!

Cheers,
Hartwig
Back to top
View user's profile Send private message
robertosfield
OSG Project Lead


Joined: 18 Mar 2009
Posts: 10908

PostPosted: Fri Jan 06, 2017 8:45 am    Post subject:
x86_64, cmd line, built OK - but warning in Xcode
Reply with quote

Hi Hartwig,

If there a minor changes that don't affect the ABI and fix warnings
then go ahead and make changes and make a github pull request for
them.

One has to be really careful when making these changes as you are only
fixing benign warnings, but with every code modification there is
danger of making a mistake that isn't picked up by the compiler or
cursory code review so you end up with a bug entering the code base.
This might sound hypothetical but I have had experience with problem a
number of times, both with mistakes I've made and ones made by
contributors that neither of us spotted until a bug was detected at a
later date.

Basically you have to assume any time you modify the code there is
danger of introducing bugs.

Robert.

On 5 January 2017 at 18:09, Hartwig Wiesmann
<> wrote:
Quote:
Hi Robert,

I fully agree with you!
But would you mind if I submit patches that at least remove some warnings of existing code by adding an appropriate cast (the code with and without the cast should be identical)? I am especially concerned about header files because then the warnings are also polluting my code (and there might be some bugs).

Example (taken from osg::Drawable):


Code:
virtual void apply(const ByteArray& array) { if (!array.empty()) _af.apply(_type,array.size(),&(array.front())); }




should be replaced by


Code:
virtual void apply(const ByteArray& array) { if (!array.empty()) _af.apply(_type,static_cast<unsigned int>(array.size()),&(array.front())); }




Doing this kind of modification in osg::Drawable alone will remove about 30 to 40 warnings already!

Thank you!

Cheers,
Hartwig

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=69889#69889








------------------
Post generated by Mail2Forum
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    OpenSceneGraph Forum Forum Index -> Build system [build] All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum

Similar Topics
Topic Author Forum Replies Posted
No new posts OpenGL warning qiaokun General 1 Thu May 25, 2017 2:57 am View latest post
No new posts Command line option for inputing X/Y ... vinothrajendran4 VirtualPlanetBuilder [vpb] 0 Wed Jan 25, 2017 7:16 am View latest post
No new posts OSG Build Error on Mac OSX with XCode... ravidavi Build system [build] 4 Mon Jul 18, 2016 6:17 am View latest post
No new posts Polygon offset for line geometries, Z... raymon General 1 Thu Jul 14, 2016 11:05 am View latest post
No new posts Line tessellation with osgUtil::Tesse... kragnfroll General 4 Wed Jul 13, 2016 9:24 am View latest post


Board Security Anti Bot Question MOD - phpBB MOD against Spam Bots
Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP