Re: New gcc 4.0.0 warnings seem spurious

2005-04-28 Thread Vincent Lefevre
On 2005-04-27 14:30:01 -0700, Mike Stump wrote: > On Apr 27, 2005, at 5:15 AM, Neil Booth wrote: > >Even better, you can turn of the warning with a cast, making your > >intent explicit to the compiler, so there's every reason to have > >it on by default. > > And, if you don't like casts, you can (

Re: New gcc 4.0.0 warnings seem spurious

2005-04-27 Thread Mike Stump
On Apr 27, 2005, at 5:15 AM, Neil Booth wrote: Even better, you can turn of the warning with a cast, making your intent explicit to the compiler, so there's every reason to have it on by default. And, if you don't like casts, you can (...)&255 or whatever.

Re: New gcc 4.0.0 warnings seem spurious

2005-04-27 Thread Gabriel Dos Reis
Vincent Lefevre <[EMAIL PROTECTED]> writes: | > Read Zack's sentence | > | > These are not constants. | > | > from | > | >http://gcc.gnu.org/ml/gcc/2005-04/msg01436.html | > | > as | > | > These (i.e. AAA, etc.) are not constant expressions. | > | > Are you happy now? | | T

Re: New gcc 4.0.0 warnings seem spurious

2005-04-27 Thread Vincent Lefevre
On 2005-04-27 18:38:52 +0200, Gabriel Dos Reis wrote: > It has been answered, but I do not believe you made the effort to > understand the answer. Now, let me asnwer it one more time. The vocabulary is important, and I find the gcc diagnostic (cited by Bruce) quite confusing. Then it is not surpr

Re: New gcc 4.0.0 warnings seem spurious

2005-04-27 Thread Gabriel Dos Reis
Vincent Lefevre <[EMAIL PROTECTED]> writes: | On 2005-04-27 17:30:25 +0200, Gabriel Dos Reis wrote: | > Vincent Lefevre <[EMAIL PROTECTED]> writes: | > | > | On 2005-04-27 15:30:39 +0200, Gabriel Dos Reis wrote: | > | > Vincent Lefevre <[EMAIL PROTECTED]> writes: | > | > | > | > [...] | > | > |

Re: New gcc 4.0.0 warnings seem spurious

2005-04-27 Thread Vincent Lefevre
On 2005-04-27 15:44:15 +0100, Dave Korn wrote: > Original Message > >From: Vincent Lefevre > >Sent: 27 April 2005 14:59 > > > On 2005-04-27 15:30:39 +0200, Gabriel Dos Reis wrote: > >> Vincent Lefevre <[EMAIL PROTECTED]> writes: > >> > >> [...] > >> > > But if they are never modifi

RE: New gcc 4.0.0 warnings seem spurious

2005-04-27 Thread Dave Korn
Original Message >From: Vincent Lefevre >Sent: 27 April 2005 15:47 > Example: the expression 1+1 is not a constant, OK then, let's see you assign a different value to it! cheers, DaveK -- Can't think of a witty .sigline today

Re: New gcc 4.0.0 warnings seem spurious

2005-04-27 Thread Vincent Lefevre
On 2005-04-27 17:30:25 +0200, Gabriel Dos Reis wrote: > Vincent Lefevre <[EMAIL PROTECTED]> writes: > > | On 2005-04-27 15:30:39 +0200, Gabriel Dos Reis wrote: > | > Vincent Lefevre <[EMAIL PROTECTED]> writes: > | > > | > [...] > | > > | > | > > But if they are never modified, they evaluate to

RE: New gcc 4.0.0 warnings seem spurious

2005-04-27 Thread Dave Korn
Original Message >From: Vincent Lefevre >Sent: 27 April 2005 14:59 > On 2005-04-27 15:30:39 +0200, Gabriel Dos Reis wrote: >> Vincent Lefevre <[EMAIL PROTECTED]> writes: >> >> [...] >> > But if they are never modified, they evaluate to constants, right? > > The fact that the

Re: New gcc 4.0.0 warnings seem spurious

2005-04-27 Thread Gabriel Dos Reis
Vincent Lefevre <[EMAIL PROTECTED]> writes: | On 2005-04-27 15:44:12 +0200, Gabriel Dos Reis wrote: | > Vincent Lefevre <[EMAIL PROTECTED]> writes: | > | > | On 2005-04-27 12:34:14 +0100, Andrew Haley wrote: | > | > You said "if they are never modified, they evaluate to constants, | > | > right?"

Re: New gcc 4.0.0 warnings seem spurious

2005-04-27 Thread Gabriel Dos Reis
Vincent Lefevre <[EMAIL PROTECTED]> writes: | On 2005-04-27 15:30:39 +0200, Gabriel Dos Reis wrote: | > Vincent Lefevre <[EMAIL PROTECTED]> writes: | > | > [...] | > | > | > > But if they are never modified, they evaluate to constants, right? | > | > > | > | > > The fact that they are not co

Re: New gcc 4.0.0 warnings seem spurious

2005-04-27 Thread Gabriel Dos Reis
Vincent Lefevre <[EMAIL PROTECTED]> writes: | On 2005-04-27 15:41:06 +0200, Gabriel Dos Reis wrote: | > Vincent Lefevre <[EMAIL PROTECTED]> writes: | > | It is said "constant expressions", not "integer constant expressions". | > | > And an integer constant expression is not a constant expression

Re: New gcc 4.0.0 warnings seem spurious

2005-04-27 Thread Vincent Lefevre
On 2005-04-27 15:26:39 +0200, Gabriel Dos Reis wrote: > Vincent Lefevre <[EMAIL PROTECTED]> writes: > > | On 2005-04-27 03:37:15 -0700, Zack Weinberg wrote: > | > Vincent Lefevre <[EMAIL PROTECTED]> writes: > | > > However it is correct to store any integer to an unsigned variable, > | > > even if

Re: New gcc 4.0.0 warnings seem spurious

2005-04-27 Thread Vincent Lefevre
On 2005-04-27 15:44:12 +0200, Gabriel Dos Reis wrote: > Vincent Lefevre <[EMAIL PROTECTED]> writes: > > | On 2005-04-27 12:34:14 +0100, Andrew Haley wrote: > | > You said "if they are never modified, they evaluate to constants, > | > right?" To which the correct answer is "no, they don't". > | >

Re: New gcc 4.0.0 warnings seem spurious

2005-04-27 Thread Vincent Lefevre
On 2005-04-27 15:30:39 +0200, Gabriel Dos Reis wrote: > Vincent Lefevre <[EMAIL PROTECTED]> writes: > > [...] > > | > > But if they are never modified, they evaluate to constants, right? > | > > > | > > The fact that they are not considered as constant expressions, > | > > is it due to the f

Re: New gcc 4.0.0 warnings seem spurious

2005-04-27 Thread Vincent Lefevre
On 2005-04-27 15:41:06 +0200, Gabriel Dos Reis wrote: > Vincent Lefevre <[EMAIL PROTECTED]> writes: > | It is said "constant expressions", not "integer constant expressions". > > And an integer constant expression is not a constant expression in > your copy of the C standard? What you are saying

Re: New gcc 4.0.0 warnings seem spurious

2005-04-27 Thread Gabriel Dos Reis
Vincent Lefevre <[EMAIL PROTECTED]> writes: | On 2005-04-27 12:34:14 +0100, Andrew Haley wrote: | > You said "if they are never modified, they evaluate to constants, | > right?" To which the correct answer is "no, they don't". | | Why not? I think the answer to that question was in the part you

Re: New gcc 4.0.0 warnings seem spurious

2005-04-27 Thread Gabriel Dos Reis
Vincent Lefevre <[EMAIL PROTECTED]> writes: | On 2005-04-27 12:29:53 +0100, Andrew Haley wrote: | > Vincent Lefevre writes: | > > The only two constraints in 6.6 are: | > > | > >[#3] Constant expressions shall not contain assignment, | > >increment, decrement, function-

Re: New gcc 4.0.0 warnings seem spurious

2005-04-27 Thread Gabriel Dos Reis
Vincent Lefevre <[EMAIL PROTECTED]> writes: [...] | > > But if they are never modified, they evaluate to constants, right? | > > | > > The fact that they are not considered as constant expressions, | > > is it due to the fact that the environment is allowed to modify | > > them? | > | > It

Re: New gcc 4.0.0 warnings seem spurious

2005-04-27 Thread Neil Booth
Vincent Lefevre wrote:- > > Before the conversion, the value is representable in the type of > the expression, and after the conversion (which is well-defined), > it is still representable in the (new) type of the expression. > 6.7.8#11 mentions the possible conversion. So, I disagree here. Warn

Re: New gcc 4.0.0 warnings seem spurious

2005-04-27 Thread Gabriel Dos Reis
Vincent Lefevre <[EMAIL PROTECTED]> writes: | On 2005-04-27 03:37:15 -0700, Zack Weinberg wrote: | > Vincent Lefevre <[EMAIL PROTECTED]> writes: | > > However it is correct to store any integer to an unsigned variable, | > > even if the original value cannot be represented. | > | > If that operat

Re: New gcc 4.0.0 warnings seem spurious

2005-04-27 Thread Gabriel Dos Reis
Zack Weinberg <[EMAIL PROTECTED]> writes: [...] | >> Bruce Lilly <[EMAIL PROTECTED]> writes: | >> > static const unsigned char AAA = 0x1U; | >> > static const unsigned char BBB = 0x2U; | >> | >> Again, C does not work the way you think. These are not constants. | > | > But if they are never mod

Re: New gcc 4.0.0 warnings seem spurious

2005-04-27 Thread Gabriel Dos Reis
Vincent Lefevre <[EMAIL PROTECTED]> writes: | > Bruce Lilly <[EMAIL PROTECTED]> writes: | > > static const unsigned char AAA = 0x1U; | > > static const unsigned char BBB = 0x2U; | > | > Again, C does not work the way you think. These are not constants. | | But if they are never modified, they e

Re: New gcc 4.0.0 warnings seem spurious

2005-04-27 Thread Vincent Lefevre
On 2005-04-27 12:34:14 +0100, Andrew Haley wrote: > You said "if they are never modified, they evaluate to constants, > right?" To which the correct answer is "no, they don't". Why not? -- Vincent Lefèvre <[EMAIL PROTECTED]> - Web: 100% accessible validated (X)HTML - Bl

Re: New gcc 4.0.0 warnings seem spurious

2005-04-27 Thread Vincent Lefevre
On 2005-04-27 12:29:53 +0100, Andrew Haley wrote: > Vincent Lefevre writes: > > The only two constraints in 6.6 are: > > > >[#3] Constant expressions shall not contain assignment, > >increment, decrement, function-call, or comma operators, > >except when they

Re: New gcc 4.0.0 warnings seem spurious

2005-04-27 Thread Andrew Haley
Vincent Lefevre writes: > On 2005-04-27 11:37:51 +0100, Andrew Haley wrote: > > Warnings are to help the programmer see where there is some code that, > > although not necessarily an error, may require some attention. This > > is a classic case of such a warning. This warning really does > >

Re: New gcc 4.0.0 warnings seem spurious

2005-04-27 Thread Andrew Haley
Vincent Lefevre writes: > On 2005-04-27 03:37:15 -0700, Zack Weinberg wrote: > > Vincent Lefevre <[EMAIL PROTECTED]> writes: > > > However it is correct to store any integer to an unsigned variable, > > > even if the original value cannot be represented. > > > > If that operation occurs at r

Re: New gcc 4.0.0 warnings seem spurious

2005-04-27 Thread Vincent Lefevre
On 2005-04-27 11:37:51 +0100, Andrew Haley wrote: > Warnings are to help the programmer see where there is some code that, > although not necessarily an error, may require some attention. This > is a classic case of such a warning. This warning really does > indicate to the programmer that there

Re: New gcc 4.0.0 warnings seem spurious

2005-04-27 Thread Vincent Lefevre
On 2005-04-27 03:37:15 -0700, Zack Weinberg wrote: > Vincent Lefevre <[EMAIL PROTECTED]> writes: > > However it is correct to store any integer to an unsigned variable, > > even if the original value cannot be represented. > > If that operation occurs at runtime it has a well-defined result. And

Re: New gcc 4.0.0 warnings seem spurious

2005-04-27 Thread Andrew Haley
Vincent Lefevre writes: > On 2005-04-26 13:15:43 -0700, Zack Weinberg wrote: > > The initializer thus tries to give a variable with type unsigned:8 > > a value that it cannot hold. The diagnostic is correct. > > However it is correct to store any integer to an unsigned variable, > even if th

Re: New gcc 4.0.0 warnings seem spurious

2005-04-27 Thread Zack Weinberg
Vincent Lefevre <[EMAIL PROTECTED]> writes: > On 2005-04-26 13:15:43 -0700, Zack Weinberg wrote: >> The initializer thus tries to give a variable with type unsigned:8 >> a value that it cannot hold. The diagnostic is correct. > > However it is correct to store any integer to an unsigned variable,

Re: New gcc 4.0.0 warnings seem spurious

2005-04-27 Thread Vincent Lefevre
On 2005-04-26 13:15:43 -0700, Zack Weinberg wrote: > The initializer thus tries to give a variable with type unsigned:8 > a value that it cannot hold. The diagnostic is correct. However it is correct to store any integer to an unsigned variable, even if the original value cannot be represented. Th

Re: New gcc 4.0.0 warnings seem spurious

2005-04-26 Thread Zack Weinberg
Bruce Lilly <[EMAIL PROTECTED]> writes: >> I don't see why you think the warnings are spurious. ~(AAA), for example, >> is 4294967294, > > No, in this context it is 254 (an 8-bit unsigned field with the LSB clear). C does not work the way you think. AAA has type unsigned int. The expression ~

Re: New gcc 4.0.0 warnings seem spurious

2005-04-26 Thread Bruce Lilly
On Tue April 26 2005 11:10, Joseph S. Myers wrote: > On Tue, 26 Apr 2005, Bruce Lilly wrote: > > > Demonstration code: > > -- > > #define AAA 0x1U > > #define BBB 0x2U > > > > struct foo { > > unsigned int bar:8; > > }; > > > > struct foo foos[] = { > > { ~(AAA) }

Re: New gcc 4.0.0 warnings seem spurious

2005-04-26 Thread Joseph S. Myers
On Tue, 26 Apr 2005, Bruce Lilly wrote: > Demonstration code: > -- > #define AAA 0x1U > #define BBB 0x2U > > struct foo { > unsigned int bar:8; > }; > > struct foo foos[] = { > { ~(AAA) }, > { ~(BBB) }, > { ~(AAA|BBB) }, > { ~(AAA&BBB) } > }; > ---

New gcc 4.0.0 warnings seem spurious

2005-04-26 Thread Bruce Lilly
Demonstration code: -- #define AAA 0x1U #define BBB 0x2U struct foo { unsigned int bar:8; }; struct foo foos[] = { { ~(AAA) }, { ~(BBB) }, { ~(AAA|BBB) }, { ~(AAA&BBB) } }; -- compiling with gcc 3.x produced no warnings, as expe