Hi!

We have the following reduced testcase code:
===========================================================
#include <iostream>
#include <stdarg.h>

using namespace std;

string FormatString(const char* szFmt, ...) {
        const int BUF_SIZE = 1024;
        char buf[BUF_SIZE] = {0};

        va_list args;

        va_start(args, szFmt);
        vsnprintf(buf, BUF_SIZE - 1, szFmt, args);
        va_end(args);

        return buf;
}

class Foo {
public:
        void Bar();
};

void Foo::Bar(){
        if (0) {
                ostream& out = cout;

                double blubb;
                out << FormatString("%f", blubb);
        }
}
===========================================================

Compiling:
bash> g++ -fmudflap -c test.cpp
test.cpp: In member function 'void Foo::Bar()':
test.cpp:33: internal compiler error: Segmentation fault
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://gcc.gnu.org/bugs.html> for instructions.

Version:
bash> gcc -v
Using built-in specs.
Target: x86_64-unknown-linux-gnu
Configured with: ../gcc-4.1-20060217/configure --prefix=/local/inst
--enable-languages=c,c++,fortran
Thread model: posix
gcc version 4.1.0 20060217 (prerelease)

ICE goes away when:
- the FormatString() is first assigned to another string and then printed out
- the enclosing if(0) is removed or replaced by if(1), therefore maybe it's in
connection with dead code elimination, yet according to the docs dead code
elimination is not active without optimization.

Interestingly the stock RedHat gcc version 4.0.1 20050727 behaves similarly:
bash> g++4 -fmudflap -c test.cpp
cc1plus: error: mf-runtime.h: No such file or directory
test.cpp: In member function 'void Foo::Bar()':
test.cpp:24: internal compiler error: Segmentation fault
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://bugzilla.redhat.com/bugzilla> for instructions.

bash> g++4 -v
Using built-in specs.
Target: x86_64-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 --with-gxx-include-dir=/usr/include/c++/3.4.3
--enable-libgcj-multifile --enable-languages=c,c++,java,f95
--enable-java-awt=gtk --with-java-home=/usr/lib/jvm/java-1.4.2-gcj-1.4.2.0/jre
--host=x86_64-redhat-linux
Thread model: posix
gcc version 4.0.1 20050727 (Red Hat 4.0.1-4.EL4.2)

It doesn't really hurt us as we can comment out the code for testing with
mudflap (doesn't work anyway...), therefore severity=minor

Preprocessed source follows...


-- 
           Summary: ICE on valid unreachable code when compiling with -
                    fmudflap
           Product: gcc
           Version: 4.1.0
            Status: UNCONFIRMED
          Severity: minor
          Priority: P3
         Component: libmudflap
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: walter dot zimmer at dlr dot de
 GCC build triplet: x86_64-unknown-linux-gnu
  GCC host triplet: x86_64-unknown-linux-gnu
GCC target triplet: x86_64-unknown-linux-gnu


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

Reply via email to