Opened 6 years ago

Closed 5 years ago

Last modified 5 years ago

#6362 closed Bugs (fixed)

Anonymous enum in bessel_ik.hpp causes problems with GCC 4.4

Reported by: Dave Steffen <dave.steffen@…> Owned by: John Maddock
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.


Attachments (0)

Change History (5)

comment:1 Changed 6 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 6 years ago by Michel Morin <mimomorin@…>

Component: Nonemath
Owner: set to John Maddock

comment:3 Changed 5 years ago by John Maddock

Milestone: To Be DeterminedBoost 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 5 years ago by John Maddock

Resolution: fixed
Status: newclosed

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

comment:5 Changed 5 years ago by John Maddock

Milestone: Boost 1.51.0Boost 1.52.0

Modify Ticket

Change Properties
Set your email in Preferences
as closed The owner will remain John Maddock.
The resolution will be deleted.

Add Comment

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

Note: See TracTickets for help on using tickets.