[ECOS] Re: casts to a type other than an integral or enumeration type in a constant-expression

Graham Stott graham.stott@btinternet.com
Thu Feb 13 01:05:00 GMT 2003


Jonathan Larmour wrote:
> Andreas Schwab wrote:
> 
>> Fred Fish <fnf@public.ninemoons.com> writes:
>>

> The warning is certainly misleading at best as an int is certainly an 
> integral type ;-). From a quick read of the C++ standard, I can't see 
> any problem with this code.
Looking at the new parser code I doubt it's complaining about the (int)
cast here but more likely the function cast within SIG_xxx. A quick test
confirms this

----------foo.cc-------------
#define SIG_DFL (void (*)())1
#define SIG_IGN 2.0

void foo (int __sighdl)
{
      switch (__sighdl)
        {
        case (int) SIG_DFL:
          ;
        case (int) SIG_IGN:
          ;
        }
}
-----------------------------
Gives

foo.cc: In function `void foo(int)':
foo.cc:8: error: a casts to a type other than an integral or enumeration type
    cannot appear in a constant-expression

So the Question is:

Are expressions of the form "(int)(void (*)())1" valid constant-expressions
in C++ ?

> Jifl





More information about the Gcc-bugs mailing list