Bug 151124 - Compiler aborts when compiling postfix file with -O2
Summary: Compiler aborts when compiling postfix file with -O2
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: Fedora
Classification: Fedora
Component: glibc
Version: rawhide
Hardware: i386
OS: Linux
medium
medium
Target Milestone: ---
Assignee: Jakub Jelinek
QA Contact:
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2005-03-15 03:54 UTC by Reuben Farrelly
Modified: 2007-11-30 22:11 UTC (History)
0 users

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2005-03-15 06:48:50 UTC
Type: ---
Embargoed:


Attachments (Terms of Use)
.i file from the compilation (112.44 KB, application/octet-stream)
2005-03-15 03:54 UTC, Reuben Farrelly
no flags Details

Description Reuben Farrelly 2005-03-15 03:54:14 UTC
Compiling the release version of Postfix-2.2 with gcc-4 is failing due to the
presence of the flag -O2 in the GCC command line.  In this case is inserted by
/usr/lib/rpm/redhat/macros (building via a spec file/RPM), but it could have
just as easily been added in a non-RPM based build.

Here's the output:

gcc -Wmissing-prototypes -Wformat -fPIC -DHAS_LDAP -DHAS_PCRE
-I/usr/include/pcre -DUSE_SASL_AUTH -I/usr/include/sasl -DUSE_TLS
-I/usr/kerberos/include   -v -save-temps -O2 -Wall -g -pipe
-Wp,-D_FORTIFY_SOURCE=2 -m32 -march=i386 -mtune=pentium4 -I. -I../../include
-DLINUX2 -c smtp-sink.c
gcc: warning: -pipe ignored because -save-temps specified
Using built-in specs.
Target: i386-redhat-linux
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man
--infodir=/usr/share/info --enable-shared --enable-threads=posix
--enable-checking=release --with-system-zlib --enable-__cxa_atexit
--disable-libunwind-exceptions --enable-languages=c,c++,objc,java,f95,ada
--enable-java-awt=gtk --host=i386-redhat-linux
Thread model: posix
gcc version 4.0.0 20050310 (Red Hat 4.0.0-0.33)
 /usr/libexec/gcc/i386-redhat-linux/4.0.0/cc1 -E -quiet -v -I/usr/include/pcre
-I/usr/include/sasl -I/usr/kerberos/include -I. -I../../include -DHAS_LDAP
-DHAS_PCRE -DUSE_SASL_AUTH -DUSE_TLS -DLINUX2 -D_FORTIFY_SOURCE=2 smtp-sink.c
-m32 -march=i386 -mtune=pentium4 -Wmissing-prototypes -Wformat -Wall -fPIC
-fworking-directory -O2 -fpch-preprocess -o smtp-sink.i
ignoring nonexistent directory
"/usr/lib/gcc/i386-redhat-linux/4.0.0/../../../../i386-redhat-linux/include"
ignoring nonexistent directory "/usr/include/pcre"
ignoring nonexistent directory "/usr/kerberos/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/include/sasl
 .
 ../../include
 /usr/local/include
 /usr/lib/gcc/i386-redhat-linux/4.0.0/include
 /usr/include
End of search list.
smtp-sink.c:2:1: warning: "/*" within comment
smtp-sink.c:3:1: warning: "/*" within comment
.. <chopped about a billion of these warnings out> ..
../../include/smtp_stream.h:52:1: warning: "/*" within comment
smtp-sink.c:538:27: error: macro "read" requires 3 arguments, but only 1 given
make: *** [smtp-sink.o] Error 1
make: *** [update] Error 1


If I remove -O2, the compiler accepts this and compiles through to completion.

The code looks like this:    (LINE538 is marked)


/* read_event - handle command or data read events */

static void read_event(int unused_event, char *context)
{
    SINK_STATE *state = (SINK_STATE *) context;

    do {
        switch (vstream_setjmp(state->stream)) {

        default:
            msg_panic("unknown error reading input");

        case SMTP_ERR_TIME:
            msg_panic("attempt to read non-readable socket");
            /* NOTREACHED */

        case SMTP_ERR_EOF:
            msg_warn("lost connection");
            disconnect(state);
            return;

        case 0:
LINE538     if (state->read(state) < 0) {
                if (msg_verbose)
                    msg_info("disconnect");
                disconnect(state);
                return;
            }
        }
    } while (vstream_peek(state->stream) > 0);
}

Comment 1 Reuben Farrelly 2005-03-15 03:54:15 UTC
Created attachment 112004 [details]
.i file from the compilation

Comment 2 Jakub Jelinek 2005-03-15 06:48:50 UTC
Compiler doesn't abort, it simply fails to compile broken code.
POSIX allows most of the functions it defines to be defined also as function-like
macros, and read is one of them.  Recent glibc's define read as macro,
therefore you need to prevent it from being expanded as function-like macro
if it is misused for something else.
This can be done either by #undef read, or better using
if ((state->read)(state) < 0) {



Note You need to log in before you can comment on or make changes to this bug.