[Boost-bugs] [Boost C++ Libraries] #6362: Anonymous enum in bessel_ik.hpp causes problems with GCC 4.4

Subject: [Boost-bugs] [Boost C++ Libraries] #6362: Anonymous enum in bessel_ik.hpp causes problems with GCC 4.4
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2012-01-06 00:17:31


#6362: Anonymous enum in bessel_ik.hpp causes problems with GCC 4.4
-----------------------------------------------------+----------------------
 Reporter: Dave Steffen <dave.steffen@…> | Type: Bugs
   Status: new | Milestone: To Be Determined
Component: None | Version: Boost 1.48.0
 Severity: Problem | Keywords: anonymous enumerations
-----------------------------------------------------+----------------------
 This is a problem with GCC 4.4, and maybe earlier: discussed in GCC bugs
 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20589 and
 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27560

 Boiling down our code is complicated, but it amounts to a template
 operator&, with boost::enable_if to constrain the template. Then, we use
 (indirectly) something out of
 boost/math/special_functions/detail/bessel_ik.hpp, which has this code
 around line 260:

 enum{
    need_i = 1,
    need_k = 2
 };
 template <typename T, typename Policy>
 int bessel_ik(T v, T x, T* I, T* K, int kind, const Policy& pol)
 {
   if(kind & need_k) {...


 At which point, GCC says: error: ‘<anonymous enum>’ is/uses anonymous type

 The issue, as near as I can tell, is that

   A) In the process of instantiating enable_if to see if it wants to use
 the templated op&, GCC tries to instantiate it with the need_k value,
 which

   B) Isn't allowed by GCC 4.4, since it was following the standardization
 process, and at that point in time

   C) the standard didn't allow anonymous enumeration types for template
 parameters.

 Gabriel Dos Reis apparently jumped up and down about this: from the GCC
 bug report,

 "and the current standard is known to be defective in that aspect,
 which is why we had the core issue in the first place."

 The fix is simply to add anything before the { in the enum declaration:

 enum name_not_really_needed{
    need_i = 1,
    need_k = 2
 };

 Although, on closer look, I don't believe that enumeration is actually
 needed (and really doesn't need to be at namespace scope). There's
 probably a very simple, and generally cleaner approach -- using global
 const ints, for example.

 Could we get this fixed? Ideally for 1.48.1? We're still on 1.47, and a
 backport would be dandy too.

 Thanks

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/6362>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:08 UTC