This is the mail archive of the ecos-discuss@sources.redhat.com mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Re: casts to a type other than an integral or enumerationtype in a constant-expression


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



--
Before posting, please read the FAQ: http://sources.redhat.com/fom/ecos
and search the list archive: http://sources.redhat.com/ml/ecos-discuss


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]