A trivial C++ 'hello world' produces mudflap violations w/ -O2, but not w/ -O0:

---
#include <iostream>
int main() {
    std::cout << "hello" << std::endl;
}
---
/opt/gcc-4.5.1/bin/gcc -Wall -O2 -fmudflap -o test test.cc -lmudflap -lstdc++
./test
*******
mudflap violation 1 (check/read): time=1280788265.017031 ptr=0x7f1d214b79e0
size=8
pc=0x7f1d214dbd31
location=`/opt/gcc-4.5.1/lib/gcc/x86_64-unknown-linux-gnu/4.5.1/../../../../include/c++/4.5.1/ostream:542:46
(main)'
      /opt/gcc-4.5.1/lib64/libmudflap.so.0(__mf_check+0x41) [0x7f1d214dbd31]
      ./test(main+0x23b) [0x400ebb]
      /lib/libc.so.6(__libc_start_main+0xfd) [0x7f1d20e6cc4d]
number of nearby objects: 0
*******
mudflap violation 2 (check/read): time=1280788265.017175 ptr=0x7f1d214bdec0
size=57
pc=0x7f1d214dbd31
location=`/opt/gcc-4.5.1/lib/gcc/x86_64-unknown-linux-gnu/4.5.1/../../../../include/c++/4.5.1/bits/locale_facets.h:866:2
(main)'
      /opt/gcc-4.5.1/lib64/libmudflap.so.0(__mf_check+0x41) [0x7f1d214dbd31]
      ./test(main+0x1ee) [0x400e6e]
      /lib/libc.so.6(__libc_start_main+0xfd) [0x7f1d20e6cc4d]
number of nearby objects: 0
*******
mudflap violation 3 (check/read): time=1280788265.017233 ptr=0x7f1d214bdec0
size=8
pc=0x7f1d214dbd31
location=`/opt/gcc-4.5.1/lib/gcc/x86_64-unknown-linux-gnu/4.5.1/../../../../include/c++/4.5.1/bits/locale_facets.h:869:27
(main)'
      /opt/gcc-4.5.1/lib64/libmudflap.so.0(__mf_check+0x41) [0x7f1d214dbd31]
      ./test(main+0x27c) [0x400efc]
      /lib/libc.so.6(__libc_start_main+0xfd) [0x7f1d20e6cc4d]
number of nearby objects: 0
*******
mudflap violation 4 (check/read): time=1280788265.017289 ptr=0x7f1d214b4de0
size=8
pc=0x7f1d214dbd31
location=`/opt/gcc-4.5.1/lib/gcc/x86_64-unknown-linux-gnu/4.5.1/../../../../include/c++/4.5.1/bits/locale_facets.h:869:27
(main)'
      /opt/gcc-4.5.1/lib64/libmudflap.so.0(__mf_check+0x41) [0x7f1d214dbd31]
      ./test(main+0x2a3) [0x400f23]
      /lib/libc.so.6(__libc_start_main+0xfd) [0x7f1d20e6cc4d]
number of nearby objects: 0
hello
---
/opt/gcc-4.5.1/bin/gcc -Wall -O0 -fmudflap -o test test.cc -lmudflap -lstdc++
./test
hello
---

Expected Behavior: No mudflap violations with -O2

gcc -v:
Using built-in specs.
COLLECT_GCC=/opt/gcc-4.5.1/bin/gcc
COLLECT_LTO_WRAPPER=/opt/gcc-4.5.1/libexec/gcc/x86_64-unknown-linux-gnu/4.5.1/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: ../gcc-4.5.1/configure --prefix=/opt/gcc-4.5.1
--disable-bootstrap --enable-languages=c,c++
Thread model: posix
gcc version 4.5.1 (GCC) 


Also fails with ubuntu 10.04's:

Using built-in specs.
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 4.4.3-4ubuntu5'
--with-bugurl=file:///usr/share/doc/gcc-4.4/README.Bugs
--enable-languages=c,c++,fortran,objc,obj-c++ --prefix=/usr --enable-shared
--enable-multiarch --enable-linker-build-id --with-system-zlib
--libexecdir=/usr/lib --without-included-gettext --enable-threads=posix
--with-gxx-include-dir=/usr/include/c++/4.4 --program-suffix=-4.4 --enable-nls
--enable-clocale=gnu --enable-libstdcxx-debug --enable-plugin --enable-objc-gc
--disable-werror --with-arch-32=i486 --with-tune=generic
--enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu
--target=x86_64-linux-gnu
Thread model: posix
gcc version 4.4.3 (Ubuntu 4.4.3-4ubuntu5)


-- 
           Summary: C++ Hello World mudflap violations
           Product: gcc
           Version: 4.5.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: bryanr81 at gmail dot com
 GCC build triplet: x86_64-linux-gnu
  GCC host triplet: x86_64-linux-gnu
GCC target triplet: x86_64-linux-gnu


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

Reply via email to