This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
gcc 2.95.2 -W warning: overflow on truncation to integer on sparc
- To: gcc bug reports <gcc-bugs at gcc dot gnu dot org>
- Subject: gcc 2.95.2 -W warning: overflow on truncation to integer on sparc
- From: Martin Sebor <sebor at roguewave dot com>
- Date: Sat, 09 Sep 2000 16:40:13 -0600
- Organization: Rogue Wave Software, Inc.
The code below produces 2 warnings when compiled with gcc -W -O2 on a
sparc (SunOS 5.7). There's no warning on any other architecture (alpha,
hppa, i86, ...). Changing the type of foo() from unsigned to int, or the
type of the literal from double to long double, or decreasing to -O
eliminates the warning.
Regards
Martin
inline unsigned foo (unsigned n)
{
return (unsigned)(n * 1.0);
}
unsigned bar ()
{
return foo (0);
}
$ gcc -v -c -O2 t.i -W
Reading specs from
/usr/local/lib/gcc-lib/sparc-sun-solaris2.7/2.95.2/specs
gcc version 2.95.2 19991024 (release)
/usr/local/lib/gcc-lib/sparc-sun-solaris2.7/2.95.2/cc1 t.i -quiet -O2
-W -version -o /var/tmp/ccbPDgIc.s
GNU C version 2.95.2 19991024 (release) (sparc-sun-solaris2.7) compiled
by GNU C version 2.95.2 19991024 (release).
t.i: In function `bar':
t.i:9: warning: overflow on truncation to integer
t.i:9: warning: overflow on truncation to integer
/usr/ccs/bin/as -V -Qy -s -o t.o /var/tmp/ccbPDgIc.s
/usr/ccs/bin/as: WorkShop Compilers 5.0 98/12/21