Bug 11445 - false positive warning with -Wunreachable-code
Summary: false positive warning with -Wunreachable-code
Status: RESOLVED DUPLICATE of bug 11370
Alias: None
Product: gcc
Classification: Unclassified
Component: c (show other bugs)
Version: 3.3.1
: P2 normal
Target Milestone: 3.4.0
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-07-06 13:52 UTC by Debian GCC Maintainers
Modified: 2005-07-23 22:49 UTC (History)
1 user (show)

See Also:
Host: i386-linux
Target: i386-linux
Build: i386-linux
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Debian GCC Maintainers 2003-07-06 13:52:47 UTC
[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.
Comment 1 Andrew Pinski 2003-07-06 14:32:16 UTC
Same bug as bug 11370 which a fix has been sumbitted for approval.

*** This bug has been marked as a duplicate of 11370 ***