Skip to content

Do not rely on std::endl function address and fix warnings#24

Merged
psi29a merged 3 commits intoOpenMW:3.6from
elsid:3.6_fix_endl
Mar 2, 2024
Merged

Do not rely on std::endl function address and fix warnings#24
psi29a merged 3 commits intoOpenMW:3.6from
elsid:3.6_fix_endl

Conversation

@elsid
Copy link

@elsid elsid commented Feb 25, 2024

Relying on the address of std::endl is a std library specific behaviour. For example in libc++ it's inline function so it may have many addresses depending on the translation unit. Basically this code from the isEndl function does not work as you could expect. In different translation units it will be evaluated into true or false which makes this function unpredictable and leads to broken behaviour. For example to failed tests in openmw which compare serialized osg::Node into osgt format.

include/osg/Plane:244:17: warning: variable 'noOn' set but not used [-Wunused-but-set-variable]
            int noOn = 0;
                ^
include/osg/Plane:273:17: warning: variable 'noOn' set but not used [-Wunused-but-set-variable]
            int noOn = 0;
                ^
@elsid elsid closed this Feb 25, 2024
Relying on the address of std::endl is a std library specific behaviour. For
example in libc++ it's inline function so it may have many addresses depending
on the translation unit.

This leads to different behaviour of osg::Node serialization using
osgDB::ReaderWriter for osgt format.
@elsid elsid reopened this Mar 1, 2024
@elsid elsid changed the title Fix build with libc++ and fix warnings Do not rely on std::endl function address and fix warnings Mar 1, 2024
@psi29a psi29a merged commit 675feae into OpenMW:3.6 Mar 2, 2024
@elsid elsid deleted the 3.6_fix_endl branch March 5, 2024 10:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants