Re: No effect of -fshort-enums..is it a bug

2005-09-23 Thread John Love-Jensen
Hi Gaurav, You could do this... q = 4294967295U Or you could use -std=iso9899:1999 (perhaps with -pedantic) for the compiler to produce an error. Assuming you are using GCC 4.x. Or if you *want* to allow that, you could do this... -std=gnu99 I'm guessing as to which version of GCC you are usin

RE: No effect of -fshort-enums..is it a bug

2005-09-23 Thread Gaurav Gautam, Noida
> > > Hi Gaurav, > > > >> Please confirm which of the two outputs is correct and why is there a > > difference in the output of two versions of compiler? > > > > Both outputs are "correct". > > > > > No, the standard is entirely unambiguous: > > --

Re: No effect of -fshort-enums..is it a bug

2005-09-23 Thread Bernhard R. Link
* Andreas Schwab <[EMAIL PROTECTED]> [050921 17:46]: > "Gaurav Gautam, Noida" <[EMAIL PROTECTED]> writes: > > Does -fshort-enum guides the size of enumeration type or the size of > > enumerator constant ? > An enumerator constant is not an object, thus it has no size of its own. > Since the enumera

Re: No effect of -fshort-enums..is it a bug

2005-09-22 Thread Paul Brook
On Thursday 22 September 2005 19:31, Daniel Jacobowitz wrote: > On Thu, Sep 22, 2005 at 12:50:39PM -0400, Robert Dewar wrote: > > of course, but the behavior of a compiler with a special implementation > > dependent switch is not specified by the standard! Switches can do any > > amount of violence

Re: No effect of -fshort-enums..is it a bug

2005-09-22 Thread Daniel Jacobowitz
On Thu, Sep 22, 2005 at 12:50:39PM -0400, Robert Dewar wrote: > of course, but the behavior of a compiler with a special implementation > dependent switch is not specified by the standard! Switches can do any > amount of violence to the standard you like, the only requirement is > that there be a d

Re: No effect of -fshort-enums..is it a bug

2005-09-22 Thread Robert Dewar
Dave Korn wrote: Please confirm which of the two outputs is correct and why is there a difference in the output of two versions of compiler? Both outputs are "correct". No, the standard is entirely unambiguous: of course, but the behavior of a compiler with a special implementation de

Re: No effect of -fshort-enums..is it a bug

2005-09-22 Thread Gabriel Dos Reis
John Love-Jensen <[EMAIL PROTECTED]> writes: | Hi Dave, Daniel, and Gaurav, | | For C99, I stand corrected. | | For C89 or C++98, I think my statement is applicable. No, for C++98 your statement is even more incorrect because enumerators (the constants) are NOT of type int -- and that has been

Re: No effect of -fshort-enums..is it a bug

2005-09-22 Thread John Love-Jensen
Hi Gaby, Dave, Daniel, and Gaurav, >This is incorrect and misleading. I concur. I retract my previous statement, and direct seekers-of-clarification to the previous posts that answered this issue. My apologies for my confusion. Sincerely, --Eljay

Re: No effect of -fshort-enums..is it a bug

2005-09-22 Thread John Love-Jensen
Hi Dave, Daniel, and Gaurav, For C99, I stand corrected. For C89 or C++98, I think my statement is applicable. (But until I double-check by reading those standards, take that with a grain of salt.) For all three, having enum be an int (signed or unsigned) is legit of course. For all three, hav

Re: No effect of -fshort-enums..is it a bug

2005-09-22 Thread Gabriel Dos Reis
John Love-Jensen <[EMAIL PROTECTED]> writes: | Hi Gaurav, | | >Please confirm which of the two outputs is correct and why is there a | difference in the output of two versions of compiler? | | Both outputs are "correct". | | (Neither output is compliant to the standard, of course, as -fshort-en

RE: No effect of -fshort-enums..is it a bug

2005-09-22 Thread Dave Korn
Original Message >From: John Love-Jensen >Sent: 22 September 2005 16:34 > Hi Gaurav, > >> Please confirm which of the two outputs is correct and why is there a > difference in the output of two versions of compiler? > > Both outputs are "correct". > No, the standard is entirely unam

Re: No effect of -fshort-enums..is it a bug

2005-09-22 Thread Daniel Jacobowitz
On Thu, Sep 22, 2005 at 10:34:19AM -0500, John Love-Jensen wrote: > Hi Gaurav, > > >Please confirm which of the two outputs is correct and why is there a > difference in the output of two versions of compiler? > > Both outputs are "correct". > > (Neither output is compliant to the standard, of c

Re: No effect of -fshort-enums..is it a bug

2005-09-22 Thread John Love-Jensen
Hi Gaurav, >Please confirm which of the two outputs is correct and why is there a difference in the output of two versions of compiler? Both outputs are "correct". (Neither output is compliant to the standard, of course, as -fshort-enums is a deviation from the standard.) Sincerely, --Eljay

Re: No effect of -fshort-enums..is it a bug

2005-09-22 Thread Neil Booth
Gaurav Gautam, Noida wrote:- > #include > int main() > { >enum aa { >a = 0, b =127 , c >}; > printf("size = %d %d %d\n", sizeof(enum aa),sizeof(b),sizeof(c)); > printf("value= %d %d %d\n", a,b,c); > return 0; > ) > > The output is > size = 1 1 1 > value= 0 127 128 > when

RE: No effect of -fshort-enums..is it a bug

2005-09-22 Thread Gaurav Gautam, Noida
> > And > > size = 1 4 4 > value= 0 127 128 > > when (GCC) 4.1.0 20050915 (experimental) is used with -fshort-enums. > > Which of the two output is standard confirming.? > > > > -Original Message- > > From: Daniel Jacobowitz [mailto:[EMAI

Re: No effect of -fshort-enums..is it a bug

2005-09-21 Thread Daniel Jacobowitz
On Wed, Sep 21, 2005 at 10:54:56AM -0400, Robert Dewar wrote: > Daniel Jacobowitz wrote: > > > >I'm not 100% sure what #3 means for enumerators whose value does not > >fit in the range of "int", but it's pretty clear that the > >implementation is not allowed to change the type of enumerators. > >

Re: No effect of -fshort-enums..is it a bug

2005-09-21 Thread Andreas Schwab
"Gaurav Gautam, Noida" <[EMAIL PROTECTED]> writes: > Does -fshort-enum guides the size of enumeration type or the size of > enumerator constant ? An enumerator constant is not an object, thus it has no size of its own. Since the enumerator constants are of type int, not the enum type, -fshort-enu

Re: No effect of -fshort-enums..is it a bug

2005-09-21 Thread Robert Dewar
Daniel Jacobowitz wrote: I'm not 100% sure what #3 means for enumerators whose value does not fit in the range of "int", but it's pretty clear that the implementation is not allowed to change the type of enumerators. Of course an implementation can do whatever it likes in response to switches,

Re: No effect of -fshort-enums..is it a bug

2005-09-21 Thread Daniel Jacobowitz
On Wed, Sep 21, 2005 at 07:03:49PM +0530, Gaurav Gautam, Noida wrote: > Thanks for the reply, > > But why is there a difference in the output of same tc, with an old gcc > compiler and a new version of compiler. > > Was there a bug in the earlier gcc. > > I have a doubt. > > Gcc manual says th

RE: No effect of -fshort-enums..is it a bug

2005-09-21 Thread Gaurav Gautam, Noida
er 21, 2005 6:10 PM > To: Gaurav Gautam, Noida > Cc: gcc@gcc.gnu.org; [EMAIL PROTECTED] > Subject: Re: No effect of -fshort-enums..is it a bug > > On Wed, Sep 21, 2005 at 05:46:58PM +0530, Gaurav Gautam, Noida wrote: > > int main() > > { > > enum aa { > &g

Re: No effect of -fshort-enums..is it a bug

2005-09-21 Thread Daniel Jacobowitz
On Wed, Sep 21, 2005 at 05:46:58PM +0530, Gaurav Gautam, Noida wrote: > int main() > { > enum aa { > a = 0, b =127 , c > }; > > printf("size = %d %d %d\n", sizeof(a),sizeof(b), sizeof(c)); > printf("value= %d %d %d\n", a,b,c); > return 0; > } >

No effect of -fshort-enums..is it a bug

2005-09-21 Thread Gaurav Gautam, Noida
Hi, I have compiled a testcase int main() { enum aa { a = 0, b =127 , c }; printf("size = %d %d %d\n", sizeof(a),sizeof(b), sizeof(c)); printf("value= %d %d %d\n", a,b,c); return 0; } On gcc (GCC) 4.1.0 20050915 (experimental) with the followi