This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Wrong warning? ISO C restric ts enumerator values to range of âintâ
On 2008-02-06 18:52:16 +0100, Manuel López-Ibáñez wrote:
> Maybe I don't understand what you are asking but from reading the code
> and relevant testcases, it seems that:
>
> * Unsigned integer constants for enum values are handled just fine by
> GCC as a extension to the C language. (See testsuite/gcc.dg/enum1.c).
The problem is the cast (suggested by Dave Korn), not the enum itself:
(int) 0x80001000
> * Being an extension, it is warned by -pedantic.
>
> So everything is working as expected, isn't it?
Oops, I forgot that my machine was reinstalled in 64 bits a few days
ago. Now, I've the same problem (i.e. no warnings) on a 32-bit machine
(though not with the latest gcc version):
ay:~> gcc --version
cc (GCC) 4.2.3 20080114 (prerelease) (Debian 4.2.2-7)
[...]
ay:~> cat tst.c
#include <stdio.h>
typedef enum OMX_ERRORTYPE {
OMX_ErrorNone = 0,
OMX_ErrorInsufficientResources = (int) 0x80001000
} OMX_ERRORTYPE;
int main (void)
{
printf ("%d\n", (int) OMX_ErrorInsufficientResources);
return 0;
}
ay:~> gcc -Wall -pedantic -std=c99 tst.c -o tst
ay:~> ./tst
-2147479552
--
Vincent Lefèvre <vincent@vinc17.org> - Web: <http://www.vinc17.org/>
100% accessible validated (X)HTML - Blog: <http://www.vinc17.org/blog/>
Work: CR INRIA - computer arithmetic / Arenaire project (LIP, ENS-Lyon)