Modify

Ticket #4297 (closed Patches: fixed)

Opened 4 years ago

Last modified 2 years ago

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

Reported by: Lénaïc Huard <lhuard@…> Owned by: igaztanaga
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

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

Change History

Changed 4 years ago by Lénaïc Huard <lhuard@…>

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

comment:1 Changed 4 years ago by igaztanaga

  • Status changed from new to closed
  • Resolution set to fixed
  • Milestone changed from Boost 1.44.0 to Boost-1.45.0

Fixed for Boost 1.45 in release branch

comment:2 Changed 3 years ago by visionofarun@…

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 Changed 3 years ago by visionofarun@…

  • Cc visionofarun@… added
  • Keywords interprocess added
  • Status changed from closed to reopened
  • Resolution fixed deleted
  • Version changed from Boost Development Trunk to Boost 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'

Changed 3 years ago by marshall

comment:4 Changed 3 years ago by marshall

Here's a patch that silences this warning.

comment:5 Changed 3 years ago by igaztanaga

  • Status changed from reopened to closed
  • Resolution set to fixed

Fixed in Boost 1.47

comment:6 Changed 3 years ago by anonymous

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

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

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 Changed 3 years ago by Lénaïc Huard <lhuard@…>

  • Status changed from closed to reopened
  • Resolution fixed deleted
  • Milestone changed from Boost 1.45.0 to Boost 1.48.0

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

comment:9 Changed 2 years ago by anonymous

this is an incredibly, massively annoying bug.

comment:10 Changed 2 years ago by igaztanaga

  • Status changed from reopened to closed
  • Resolution set to fixed

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

View

Add a comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
The resolution will be deleted. Next status will be 'reopened'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.