Boost logo

Boost :

Subject: Re: [boost] [mpl] int_<INT_MIN> fails to compile under gcc 4.6
From: Vicente Botet (vicente.botet_at_[hidden])
Date: 2011-03-06 14:30:47


Stirling Westrup wrote:
>
> On Sun, Mar 6, 2011 at 7:24 AM, Philipp Reh wrote:
>> Stirling Westrup wrote:
>>
>>> On Sun, Mar 6, 2011 at 5:50 AM, Philipp Reh wrote:
>>>> Stirling Westrup wrote:
>>>>
>>>>> I'm not actually sure if this is a gcc regression, or a bug in mpl,
>>>>> but the following code, which compiles under gcc 4.5, doesn't do so
>>>>> under gcc 4.6:
>>>>>
>>>>> #include
>>>>> #include
>>>>> typedef boost::mpl::int_ Foo;
>>>>> Foo f;
>>>>>
>>>>>
>>>>> It produces the errors:
>>>>>
>>>>> /usr/local/include/boost/mpl/aux_/integral_wrapper.hpp: In
>>>>> instantiation of ‘mpl_::int_<-0x00000000080000000>’:
>>>>> test_test.cpp:8:27:   instantiated from here
>>>>> /usr/local/include/boost/mpl/aux_/integral_wrapper.hpp:73:96: error:
>>>>> ‘2147483647’ is not a valid template argument for type ‘int’ because
>>>>> it is a non-constant expression
>>>>> /usr/local/include/boost/mpl/aux_/integral_wrapper.hpp:73:96: error:
>>>>> overflow in constant expression [-fpermissive]
>>>>>
>>>>>
>>>>> I've already created a trak ticket for this (#5268), but was wondering
>>>>> if anyone had any insights as to its cause and/or any workarounds. My
>>>>> guess is that its related to gcc rewriting parts of its constant
>>>>> folding code to support constexpr.
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>
>>>> I can confirm that. INT_MIN isn't the only problem, it fails for a lot
>>>> of
>>>> other values as well.
>>>> Can you please raise this issue on the gcc bugtracker because the
>>>> release
>>>> is very close.
>>>>
>>>
>>> Okay, I have done so. Its bug #48003 on the GCC bugtracker.
>>>
>>>
>>>
>>
>> Thanks. After looking further into this I realized that mpl tries to
>> calculate INT_MIN-1 which, of course, is undefined. But I'm still not
>> sure
>> if this is a gcc bug or not because the typedef isn't used and I don't
>> know
>> if gcc should evaluate this.
>
> An equally important questions is what should mpl do if someone DOES
> ask for the prior of int_. Should it generate an error, throw
> an exception, return INT_MIN, or wrap around to INT_MAX?
>
> I can see arguments for most of these. Maybe it needs to be
> policy-defined somehow?
>
>

Hi,

I provided a patch for this problem more than a month a go. I hope that it
could be included in 1.47.

Best,
Vicente

--
View this message in context: http://boost.2283326.n4.nabble.com/mpl-int-INT-MIN-fails-to-compile-under-gcc-4-6-tp3337239p3337936.html
Sent from the Boost - Dev mailing list archive at Nabble.com.

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk