This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC 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]

[Bug c/41138] Inconsistent (incorrect?) "overflow in implicit constant conversion" warning



------- Comment #1 from bugs at nospam dot pz dot podzone dot net  2009-08-21 13:31 -------
$ cat foo.c
unsigned char foo;

Also note the inconsistency between x86 gcc and avr-gcc:

void test(void)
{
  foo &= ~0xff;                 /* warning */
  foo &= ~0xfe;                 /* no warning */

  foo &= 65280;                 /* warning */
  foo &= 65280L;                /* warning */
  foo &= 65280U;                /* no warning */
  foo &= 65280LU;               /* no warning */

  foo &= 0xff00;                /* warning only with x86 gcc */
  foo &= 0xff00L;               /* warning */
  foo &= 0xff00U;               /* no warning */
  foo &= 0xff00LU;              /* no warning */

  foo &= 65281;                 /* no warning */
  foo &= 65281L;                /* no warning */
  foo &= 65281U;                /* no warning */
  foo &= 65281LU;               /* no warning */

  foo &= 0xff01;                /* no warning */
  foo &= 0xff01L;               /* no warning */
  foo &= 0xff01U;               /* no warning */
  foo &= 0xff01LU;              /* no warning */
}
$ avr-gcc -c foo.c
foo.c: In function 'test':
foo.c:5: warning: overflow in implicit constant conversion
foo.c:8: warning: overflow in implicit constant conversion
foo.c:9: warning: overflow in implicit constant conversion
foo.c:14: warning: overflow in implicit constant conversion
$ gcc-4 -c foo.c
foo.c: In function 'test':
foo.c:5: warning: overflow in implicit constant conversion
foo.c:8: warning: overflow in implicit constant conversion
foo.c:9: warning: overflow in implicit constant conversion
foo.c:13: warning: overflow in implicit constant conversion
foo.c:14: warning: overflow in implicit constant conversion
$ avr-gcc --version
avr-gcc.exe (WinAVR 20090313) 4.3.2
Copyright (C) 2008 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

$ gcc-4 --version
gcc-4 (GCC) 4.3.2 20080827 (beta) 2
Copyright (C) 2008 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

$


-- 

bugs at nospam dot pz dot podzone dot net changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bugs at nospam dot pz dot
                   |                            |podzone dot net


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41138


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