Opened 14 years ago

Closed 14 years ago

Last modified 14 years ago

#2961 closed Bugs (fixed)

Boost 1.38.0 fails to compile on g++-4.0.2

Reported by: Alex Shapiro <alexsh@…> Owned by: John Maddock
Milestone: To Be Determined Component: math
Version: Boost 1.38.0 Severity: Showstopper
Keywords: 4.0.2, math, test_is_policy Cc:

Description

Boost 1.38.0 fails to compile on g++-4.0.2 on x86 Linux (while -4.0.1 is a tested target). The code compiles on g++-3.4.3.

The offending file is source:/tags/release/Boost_1_38_0/boost/math/policies/policy.hpp . I'm sorry, that I don't have the full error message here, it's at work, and I don't have the specific compiler setup at home.

namespace detail{

template <class A1, 
          class A2, 
          class A3,
          class A4,
          class A5,
          class A6,
          class A7,
          class A8,
          class A9,
          class A10,
          class A11>
char test_is_policy(const policy<A1,A2,A3,A4,A5,A6,A7,A8,A9,A10,A11>*);
double test_is_policy(...);

template <class P>
struct is_policy_imp
{
   BOOST_STATIC_CONSTANT(bool, value = (sizeof(test_is_policy(static_cast<P*>(0))) == 1));
};

}

The error says that: "test_is_policy" undefined at scope , at line BOOST_STATIC_CONSTANT(bool, value = (sizeof(test_is_policy(static_cast<P*>(0))) == 1));

Solution:

Replace sizeof(test_is_policy(static_cast<P*>(0))) with sizeof(boost::math::policy::detail::test_is_policy(static_cast<P*>(0)))

Note: the same fix probably applies to source:/trunk/boost/math/policies/policy.hpp

Change History (4)

comment:1 by Alex Shapiro <alexsh@…>, 14 years ago

I'm of course an idiot, the suggested fix is sizeof(boost::math::policies::detail::test_is_policy(static_cast<P*>(0)))

comment:2 by John Maddock, 14 years ago

Milestone: Boost 1.39.0To Be Determined
Resolution: fixed
Status: newclosed

Fixed in Trunk, fix will have to wait for 1.40 now for release branch.

Also note that later gcc versions have no such issues.

comment:3 by John Maddock, 14 years ago

(In [52513]) Fixes #2961. GCC-4.0 workaround.

comment:4 by Alex Shapiro <alexsh@…>, 14 years ago

Thanks I know that on later compilers it compiles without an issue. Unfortunately, upgrading the compiler version is problematic.

Note: See TracTickets for help on using tickets.