[Bug optimization/11937] New: bogus warning while compiling gcc/function.c

gcc-bugzilla at gcc dot gnu dot org gcc-bugzilla@gcc.gnu.org
Sat Aug 16 00:36:00 GMT 2003


PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

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

           Summary: bogus warning while compiling gcc/function.c
           Product: gcc
           Version: 3.3
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: optimization
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: uwe at netbsd dot org
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: i386-unknown-freebsd4.8
  GCC host triplet: i386-unknown-freebsd4.8
GCC target triplet: shle--netbsdelf


I'm using this compiler to compile the same version of the gcc for
NetBSD/hcpsh

host: shle--netbsdelf
build: i386--freebsd4.8 
target: shle--netbsdelf

configured with: ../configure --prefix=/var/tmp/xtarget --target=shle--netbsdelf --host=shle--netbsdelf --build=i386--freebsd4.8 --disable-multilib --disable-shared --enable-languages=c

While compiling function.c the warning about `and' of mutually
exclusive equal-tests is always 0 is produced:

shle--netbsdelf-gcc -save-temps -c -g -O2 -DIN_GCC   -W -Wall -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes -Wtraditional -pedantic -Wno-long-long   -DHAVE_CONFIG_H    -I. -I. -I../../gcc -I../../gcc/. -I../../gcc/config -I../../gcc/../include ../../gcc/function.c -o function.o
../../gcc/function.c: In function `aggregate_value_p':
../../gcc/function.c:4283: warning: suggest parentheses around && within ||
../../gcc/function.c: In function `assign_parms':
../../gcc/function.c:4740: warning: `and' of mutually exclusive equal-tests is always 0

I saw this warning with gcc-3.3 release and also with gcc-3.3.1
release as imported into the NetBSD source tree.

The warning is triggered by turning optimization on.  Compiling with
-O0 doesn't produce the warning.

The warning about line 4283 is not present for 3.3 and 3.3.1 releases
and is not pertinent to this bug report.

The offending line is:

    else if (PARM_BOUNDARY % BITS_PER_WORD != 0)

that expands to:

    else if (((target_flags & (1<<0)) ? 64 : 32) % (8 * (((target_flags & (1<<0)) && ! (target_flags & (1<<8))) ? 8 : 4)) != 0)


In particular the following subexpression causes the warning:

    ((target_flags & (1<<0)) && ! (target_flags & (1<<8)))

which is just the TARGET_SHMEDIA macro that is used all over the place
without any problems.

I did some debugging (sorry, but I know next to nothing about gcc
internals) and if I'm reading the output of dump_node correctly, the
fold-const.c:fold_truthop() complains about the tree that corresponds
to the following C expression:

    ((target_flags & 0x101) == 1) && ((target_flags & 1) == 0)

where the first occurence of `target_flags' is actually a
bit_field_ref node.

Now, the lhs of this `and' is the correct folding of the

    ((target_flags & (1<<0)) && ! (target_flags & (1<<8)))

TARGET_SHMEDIA macro, but I have no idea where the rhs comes from.

After looking through the ChangeLog I thought that might be some
shared structures are modified, so I tried to apply the fix from the
gcc-3_3-rhl-branch:

        * fold-const.c (fold): Never modify argument passed to fold, instead
        change a copy and return it.
        * convert.c (convert_to_integer): Likewise.

by pulling the following diffs:

    convert.c: 1.19 -> 1.19.18.1
    fold-constant.c: 1.227.2.3.4.1 -> 1.227.2.3.4.2
    
but that didn't help (same warning) and didn't produce any errors with
ENABLE_FOLD_CHECKING.

This warning seems to indicate a bug in optimizer.

gcc-3.4-20030813 snapshot does not have this problem.

However, since the next release of NetBSD will be using gcc 3.3.1 as
the system compiler, it would be very nice to have a fix or a
work-around for this bug on the 3.3 branch.

Environment:
System: FreeBSD vortex.sparc.spb.su 4.8-STABLE FreeBSD 4.8-STABLE #0: Wed Jun 4 13:52:39 MSD 2003 root@vortex.sparc.spb.su:/usr/obj/usr/src/sys/VORTEX i386

host: i386-unknown-freebsd4.8
build: i386-unknown-freebsd4.8
target: shle--netbsdelf
configured with: ../configure --prefix=/var/tmp/xtools --target=shle--netbsdelf --disable-multilib --disable-shared --enable-languages=c

How-To-Repeat:

With a gcc from the 3.3 branch targeting shle--netbsdelf (probably,
any SuperH target) try to compile the following file:



More information about the Gcc-bugs mailing list