Ticket #6362 (closed Bugs: fixed)

Opened 3 years ago

Last modified 3 years ago

Anonymous enum in bessel_ik.hpp causes problems with GCC 4.4

Reported by: Dave Steffen <dave.steffen@…> Owned by: johnmaddock
Milestone: Boost 1.52.0 Component: math
Version: Boost 1.48.0 Severity: Problem
Keywords: anonymous enumerations Cc:


This is a problem with GCC 4.4, and maybe earlier: discussed in GCC bugs and

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:


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.



Change History

comment:1 Changed 3 years ago by Dave Steffen <dave.steffen@…>

Let me add, that my suggestions are workarounds -- the real problem is in the version of the standard that GCC 4.4 implemented. However, the anonymous enum is A) not really needed; and B) although it's valid code, it combines with some of our AFAWKT valid code, to produce code GCC 4.4 rejects. We haven't found any way out of this, except to move to GCC 4.5, which isn't an option since 4.4 is part of our delivery platform.

Thanks very much.

-- Dave Steffen, Ph.D.

Software Developer, Numerica Corp. (

comment:2 Changed 3 years ago by Michel Morin <mimomorin@…>

  • Owner set to johnmaddock
  • Component changed from None to math

comment:3 Changed 3 years ago by johnmaddock

  • Milestone changed from To Be Determined to Boost 1.51.0

Apologies for the long delay, I'm behind on bug fixes as you can tell :-(

There's no chance of a back port (other than a patch - which you have already), but I will try and get this fixed for the next release.

comment:4 Changed 3 years ago by johnmaddock

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

(In [79421]) Ditch anonymous union - it causes GCC-4.4 to choke. Fixes #6362.

comment:5 Changed 3 years ago by johnmaddock

  • Milestone changed from Boost 1.51.0 to Boost 1.52.0

Add a comment

Modify Ticket

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

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

Note: See TracTickets for help on using tickets.