public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/42476]  New: "warning: will never be executed" about code which is executed with "-Wunreachable-code"
@ 2009-12-23 11:20 agraf at znc dot in
  2009-12-23 14:37 ` [Bug middle-end/42476] " pinskia at gcc dot gnu dot org
  2009-12-31 15:44 ` rguenth at gcc dot gnu dot org
  0 siblings, 2 replies; 3+ messages in thread
From: agraf at znc dot in @ 2009-12-23 11:20 UTC (permalink / raw)
  To: gcc-bugs

Compiling the following code snippet:

int main(int argc, char **argv)
{
        int i;
        int asize = 3;
        int array[3];

        for (i = asize - 1; i < asize; i++)
                array[i] = 42;

        for (i = 0; i < asize; i++)
                printf("%i\n", array[i]);
}

with "gcc -O -Wunreachable-code gccbug.c" shows the following warning message:

gccbug.c: In function 'main':
gccbug.c:8: warning: will never be executed

(Where line 8 is the body of the first for-loop, array[i] = 42;)

Though, array[2] is set to 42, as the later printf shows when executing.

When replacing the "- 1" of line 7 with an higher value, e.g. "- 2", the
warning disappears. Not passing "-O" to the compiler lets the warning
disappear, too.

I tested it with two versions of gcc. The first:
Using built-in specs.
Target: x86_64-pc-linux-gnu
Configured with: /var/tmp/portage/sys-devel/gcc-4.3.4/work/gcc-4.3.4/configure
--prefix=/usr --bindir=/usr/x86_64-pc-linux-gnu/gcc-bin/4.3.4
--includedir=/usr/lib/gcc/x86_64-pc-linux-gnu/4.3.4/include
--datadir=/usr/share/gcc-data/x86_64-pc-linux-gnu/4.3.4
--mandir=/usr/share/gcc-data/x86_64-pc-linux-gnu/4.3.4/man
--infodir=/usr/share/gcc-data/x86_64-pc-linux-gnu/4.3.4/info
--with-gxx-include-dir=/usr/lib/gcc/x86_64-pc-linux-gnu/4.3.4/include/g++-v4
--host=x86_64-pc-linux-gnu --build=x86_64-pc-linux-gnu --disable-altivec
--disable-fixed-point --enable-nls --without-included-gettext
--with-system-zlib --disable-checking --disable-werror --enable-secureplt
--enable-multilib --enable-libmudflap --disable-libssp --enable-libgomp
--disable-libgcj --enable-languages=c,c++,treelang,fortran --enable-shared
--enable-threads=posix --enable-__cxa_atexit --enable-clocale=gnu
--with-bugurl=http://bugs.gentoo.org/ --with-pkgversion='Gentoo 4.3.4 p1.0,
pie-10.1.5'
Thread model: posix
gcc version 4.3.4 (Gentoo 4.3.4 p1.0, pie-10.1.5) 

The second:
Using built-in specs.
Target: arm-elf
Configured with: /tmp/gcc.ndS8/gcc-4.4.1/configure --enable-languages=c
--with-mpfr=/usr --without-headers --target=arm-elf --prefix=/usr/local/arm-elf
--with-local-prefix=/usr/local/arm-elf --disable-werror --disable-multilib
--disable-shared --disable-nls --disable-libssp --with-arch=armv4t
--with-cpu=arm7tdmi-s
Thread model: single
gcc version 4.4.1 (GCC) 

The warning appears with both gcc versions.


-- 
           Summary: "warning: will never be executed" about code which is
                    executed with "-Wunreachable-code"
           Product: gcc
           Version: 4.4.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: agraf at znc dot in


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


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug middle-end/42476] "warning: will never be executed" about code which is executed with "-Wunreachable-code"
  2009-12-23 11:20 [Bug c/42476] New: "warning: will never be executed" about code which is executed with "-Wunreachable-code" agraf at znc dot in
@ 2009-12-23 14:37 ` pinskia at gcc dot gnu dot org
  2009-12-31 15:44 ` rguenth at gcc dot gnu dot org
  1 sibling, 0 replies; 3+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2009-12-23 14:37 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from pinskia at gcc dot gnu dot org  2009-12-23 14:37 -------
Note -Wunreachable-code has since ben removed from the trunk ...


-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
          Component|c                           |middle-end


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


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug middle-end/42476] "warning: will never be executed" about code which is executed with "-Wunreachable-code"
  2009-12-23 11:20 [Bug c/42476] New: "warning: will never be executed" about code which is executed with "-Wunreachable-code" agraf at znc dot in
  2009-12-23 14:37 ` [Bug middle-end/42476] " pinskia at gcc dot gnu dot org
@ 2009-12-31 15:44 ` rguenth at gcc dot gnu dot org
  1 sibling, 0 replies; 3+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2009-12-31 15:44 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from rguenth at gcc dot gnu dot org  2009-12-31 15:44 -------
-Wunreachable-code is broken and has been removed.


-- 

rguenth at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |WONTFIX


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


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2009-12-31 15:44 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-12-23 11:20 [Bug c/42476] New: "warning: will never be executed" about code which is executed with "-Wunreachable-code" agraf at znc dot in
2009-12-23 14:37 ` [Bug middle-end/42476] " pinskia at gcc dot gnu dot org
2009-12-31 15:44 ` rguenth at gcc dot gnu dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).