Opened 12 years ago

Closed 11 years ago

#4297 closed Patches (fixed)

[PATCH] Fix for warning: enumeral and non-enumeral type in conditional expression

Reported by: Lénaïc Huard <lhuard@…> Owned by: Ion Gaztañaga
Milestone: Boost 1.48.0 Component: interprocess
Version: Boost 1.45.0 Severity: Cosmetic
Keywords: interprocess Cc: visionofarun@…

Description

Hello,

When compiling some programs using boost.interprocess with gcc, we get a bunch of warning messages like:

include/boost/interprocess/mem_algo/rbtree_best_fit.hpp:323: warning: enumeral and non-enumeral type in conditional expression

The attached patch aims at fixing those warnings.

BRgds, Lénaïc.

Attachments (2)

boost_interprocess_2.patch (12.6 KB ) - added by Lénaïc Huard <lhuard@…> 12 years ago.
Patch fixing the warnings: enumeral and non-enumeral type in conditional expression
mtc-4297.patch (509 bytes ) - added by Marshall Clow 12 years ago.

Download all attachments as: .zip

Change History (12)

by Lénaïc Huard <lhuard@…>, 12 years ago

Attachment: boost_interprocess_2.patch added

Patch fixing the warnings: enumeral and non-enumeral type in conditional expression

comment:1 by Ion Gaztañaga, 12 years ago

Milestone: Boost 1.44.0Boost-1.45.0
Resolution: fixed
Status: newclosed

Fixed for Boost 1.45 in release branch

comment:2 by visionofarun@…, 12 years ago

Hi,

I'm reopening the ticket. This ticket appears in Boost 1.45.0 release notes. But seems like its not fixed yet. There are still warning messages with "g++ -W".

#include <boost/interprocess/managed_shared_memory.hpp>
int main()
{
   boost::interprocess::managed_shared_memory *mem;
   return 0;
}
g++ -c -W -fvisibility=hidden -g -Wall  1.cpp -o 1 -I/usr/local/include/boost-1.45.0/
In file included from /usr/local/include/boost-1.45.0/boost/interprocess/detail/managed_memory_impl.hpp:22,
                 from /usr/local/include/boost-1.45.0/boost/interprocess/managed_shared_memory.hpp:21,
                 from 1.cpp:1:
/usr/local/include/boost-1.45.0/boost/interprocess/mem_algo/rbtree_best_fit.hpp:321: warning: enumeral and non-enumeral type in conditional expression
1.cpp: In function 'int main()':
1.cpp:5: warning: unused variable 'mem'

comment:3 by visionofarun@…, 12 years ago

Cc: visionofarun@… added
Keywords: interprocess added
Resolution: fixed
Status: closedreopened
Version: Boost Development TrunkBoost 1.45.0

Hi,

Sorry for posting above.

I'm reopening the ticket. This ticket appears in Boost 1.45.0 release notes. But seems like its not fixed yet. There are still warning messages with "g++ -W".

#include <boost/interprocess/managed_shared_memory.hpp>
int main()
{
   boost::interprocess::managed_shared_memory *mem;
   return 0;
}
g++ -c -W -fvisibility=hidden -g -Wall  1.cpp -o 1 -I/usr/local/include/boost-1.45.0/
In file included from /usr/local/include/boost-1.45.0/boost/interprocess/detail/managed_memory_impl.hpp:22,
                 from /usr/local/include/boost-1.45.0/boost/interprocess/managed_shared_memory.hpp:21,
                 from 1.cpp:1:
/usr/local/include/boost-1.45.0/boost/interprocess/mem_algo/rbtree_best_fit.hpp:321: warning: enumeral and non-enumeral type in conditional expression
1.cpp: In function 'int main()':
1.cpp:5: warning: unused variable 'mem'

by Marshall Clow, 12 years ago

Attachment: mtc-4297.patch added

comment:4 by Marshall Clow, 12 years ago

Here's a patch that silences this warning.

comment:5 by Ion Gaztañaga, 12 years ago

Resolution: fixed
Status: reopenedclosed

Fixed in Boost 1.47

comment:6 by anonymous, 11 years ago

i have installed Boost 1.47 right in this moment and it seems like this warning is still persistent...

comment:7 by Lénaïc Huard <lhuard@…>, 11 years ago

Indeed, I confirm that the warning is still present with Boost 1.47.

The clean way to fix it is definitely to replace all the enums in metafunctions by the usage of BOOST_STATIC_CONSTANT as recommended in the Coding Guidelines for Integral Constant Expressions page and as I proposed in boost_interprocess_2.patch.

But as far as I can see, my patch has still not been applied in Boost 1.47.

Ex: type_traits.hpp of Boost 1.47

There are still enums whereas I replaced them by BOOST_STATIC_CONSTANT in boost_interprocess_2.patch.

comment:8 by Lénaïc Huard <lhuard@…>, 11 years ago

Milestone: Boost 1.45.0Boost 1.48.0
Resolution: fixed
Status: closedreopened

As mentioned above, the warning is still present. The provided patch has not been applied.

comment:9 by anonymous, 11 years ago

this is an incredibly, massively annoying bug.

comment:10 by Ion Gaztañaga, 11 years ago

Resolution: fixed
Status: reopenedclosed

Fixed in trunk, replaced all enum uses with static const values.

Note: See TracTickets for help on using tickets.