Re: MPL integral wrapper failure on gcc4

Jeff Garland writes:
I realize this is an experimental compiler, but I notice date-time isn't building because of an MPL failure. Similar problem in the MPL tests. I looked at the code, but I have no idea what the problem could be, possibly something simple?
Just looked into it, and it appears to be a GCC bug: they seem to disallow any cast notation in integral constant expressions, while section 5.19 [expr.const] para 1 explicitly allows type conversions to integral or enumeration types: [...] Floating literals (2.13.3) can appear only if they are cast to integral or enumeration types. Only type conversions to integral or enumeration types can be used. [...] If you could verify that the following stripped down version of the code in question is rejected, I'd submit a corresponding bug report: template< int n > struct int_ {}; typedef int_< static_cast<int>(5) > n; -- Aleksey Gurtovoy MetaCommunications Engineering

On Tue, Mar 01, 2005 at 03:59:36AM -0600, Aleksey Gurtovoy wrote:
Jeff Garland writes:
I realize this is an experimental compiler, but I notice date-time isn't building because of an MPL failure. Similar problem in the MPL tests. I looked at the code, but I have no idea what the problem could be, possibly something simple?
Just looked into it, and it appears to be a GCC bug: they seem to disallow any cast notation in integral constant expressions, while section 5.19 [expr.const] para 1 explicitly allows type conversions to integral or enumeration types:
[...] Floating literals (2.13.3) can appear only if they are cast to integral or enumeration types. Only type conversions to integral or enumeration types can be used. [...]
If you could verify that the following stripped down version of the code in question is rejected, I'd submit a corresponding bug report:
template< int n > struct int_ {}; typedef int_< static_cast<int>(5) > n;
This is possibly related to a recent change to deprecate a GCC extension, see the note I added, second paragraph from the bottom, here: http://gcc.gnu.org/onlinedocs/gcc/Deprecated-Features.html#Deprecated-Featur... I'll look into whether that change was the cause. jon -- "Self-respect: the secure feeling that no one, as yet, is suspicious." - H.L. Mencken

On Tue, Mar 01, 2005 at 03:59:36AM -0600, Aleksey Gurtovoy wrote:
If you could verify that the following stripped down version of the code in question is rejected, I'd submit a corresponding bug report:
template< int n > struct int_ {}; typedef int_< static_cast<int>(5) > n;
This works fine, as do all simplifications of the code I've tried. I haven't found a minimal testcase yet... jon -- "What contemptible scoundrel stole the cork from my lunch?" - W.C. Fields

On Tue, Mar 01, 2005 at 03:59:36AM -0600, Aleksey Gurtovoy wrote:
Jeff Garland writes:
I realize this is an experimental compiler, but I notice date-time isn't building because of an MPL failure. Similar problem in the MPL tests. I looked at the code, but I have no idea what the problem could be, possibly something simple?
Just looked into it, and it appears to be a GCC bug: they seem to disallow any cast notation in integral constant expressions, while section 5.19 [expr.const] para 1 explicitly allows type conversions to integral or enumeration types:
[...] Floating literals (2.13.3) can appear only if they are cast to integral or enumeration types. Only type conversions to integral or enumeration types can be used. [...]
If you could verify that the following stripped down version of the code in question is rejected, I'd submit a corresponding bug report:
template< int n > struct int_ {}; typedef int_< static_cast<int>(5) > n;
This is the minimum that fails: template<typename T, T N> struct int_ { static const T value = N; typedef int_< T, static_cast<T>(value+1) > next; }; GCC compiles this if you use "n" in the integral constant expression, rather than "value" typedef int_< T, static_cast<T>(N+1) > next; I'll file a GCC PR jon -- "Malt does more than Milton can To justify God's ways to man." - Housman, A. E. (1859 - 1936)

Jonathan Wakely wrote:
This is the minimum that fails:
template<typename T, T N> struct int_ { static const T value = N; typedef int_< T, static_cast<T>(value+1) > next; };
GCC compiles this if you use "n" in the integral constant expression, rather than "value"
typedef int_< T, static_cast<T>(N+1) > next;
I'll file a GCC PR
Giovanni has reported the bug already, see http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20220 It has been fixed recently. Regards, m
participants (3)
-
Aleksey Gurtovoy
-
Jonathan Wakely
-
Martin Wille