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/11445] New: false positive warning with -Wunreachable-code


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

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

           Summary: false positive warning with -Wunreachable-code
           Product: gcc
           Version: 3.3.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: debian-gcc at lists dot debian dot org
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: i386-linux
  GCC host triplet: i386-linux
GCC target triplet: i386-linux

[forwarded from http://bugs.debian.org/200140]

rechecked with 3.3 CVS and HEAD 20030706

#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>

extern const char *program_name;

static void printf_checked(const char *fmt, ...)
{
    va_list args;

    va_start(args, fmt);
    if (vfprintf(stdout, fmt, args) < 0) {
        perror(program_name);
        exit(1);
    }
    va_end(args);
}

$ gcc -Wunreachable-code -c foo.c
foo.c: In function `printf_checked':
foo.c:16: warning: will never be executed

This is the va_end statement, which will be executed, whenever the
vfprintf() succeeds. The documentation says that this message can appear
even if some part of the statement will not be executed, but that would
be rather strange here, as va_end() is a builtin.


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