This is the mail archive of the cygwin mailing list for the Cygwin 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]

g++-5.2.0 miscompiles a simple program


g++-5.2.0 miscompiles the following program so badly, that gdb can't
even break at the exe's entry point.

$ cat main.cpp
#include <string>
#include <iostream>


using namespace std;

int main()
{
        string s = "hello";
        cout<<s;
}

$ g++ -v
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-pc-cygwin/5.2.0/lto-wrapper.exe
Target: x86_64-pc-cygwin
Configured with:
/cygdrive/i/szsz/tmpp/gcc/gcc-5.2.0-1.x86_64/src/gcc-5.2.0/configure
--srcdir=/cygdrive/i/szsz/tmpp/gcc/gcc-5.2.0-1.x86_64/src/gcc-5.2.0
--prefix=/usr --exec-prefix=/usr --localstatedir=/var
--sysconfdir=/etc --docdir=/usr/share/doc/gcc
--htmldir=/usr/share/doc/gcc/html -C --build=x86_64-pc-cygwin
--host=x86_64-pc-cygwin --target=x86_64-pc-cygwin
--without-libiconv-prefix --without-libintl-prefix
--libexecdir=/usr/lib --enable-shared --enable-shared-libgcc
--enable-static --enable-version-specific-runtime-libs
--enable-bootstrap --enable-__cxa_atexit --with-dwarf2
--with-tune=generic
--enable-languages=ada,c,c++,fortran,lto,objc,obj-c++
--enable-graphite --enable-threads=posix --enable-libatomic
--enable-libgomp --disable-libitm --enable-libquadmath
--enable-libquadmath-support --enable-libssp --enable-libada
--enable-libgcj-sublibs --disable-java-awt --disable-symvers
--with-ecj-jar=/usr/share/java/ecj.jar --with-gnu-ld --with-gnu-as
--with-cloog-include=/usr/include/cloog-isl --without-libiconv-prefix
--without-libintl-prefix --with-system-zlib --enable-linker-build-id
Thread model: posix
gcc version 5.2.0 (GCC)

$ g++ -g main.cpp

$ gdb a.exe
GNU gdb (GDB) Cygwin 7.9.1-1
Copyright (C) 2015 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-pc-cygwin".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from a.exe...done.
(gdb) info file
Symbols from "/cygdrive/c/Users/piotrek/ClionProjects/untitled2/a.exe".
Local exec file:
        `/cygdrive/c/Users/piotrek/ClionProjects/untitled2/a.exe',
file type pei-x86-64.
        Entry point: 0x100401000
        0x0000000100401000 - 0x00000001004018b0 is .text
        0x0000000100402000 - 0x0000000100402088 is .data
        0x0000000100403000 - 0x00000001004033d8 is .rdata
        0x0000000100404000 - 0x0000000100404035 is .buildid
        0x0000000100405000 - 0x00000001004050f0 is .pdata
        0x0000000100406000 - 0x00000001004060b4 is .xdata
        0x0000000100407000 - 0x0000000100407220 is .bss
        0x0000000100408000 - 0x0000000100408518 is .idata
        0x0000000100409000 - 0x00000001004094e8 is .rsrc
(gdb) break *0x100401000
Breakpoint 1 at 0x100401000: file
/usr/src/debug/cygwin-2.3.1-1/winsup/cygwin/crt0.c, line 23.
(gdb) run
Starting program: /cygdrive/c/Users/piotrek/ClionProjects/untitled2/a.exe
[New Thread 8496.0x20c8]
[New Thread 8496.0x1f54]
[New Thread 8496.0x1084]
[New Thread 8496.0x18a0]
[Thread 8496.0x1f54 exited with code 3221225785]
[Thread 8496.0x18a0 exited with code 3221225785]
During startup program exited with code 0xc0000139.
(gdb)

Interestingly, compiling with -O2 (but not -O1) makes the program work
correctly.

I'm new to Cygwin, so perhaps there's something obvious I'm missing?

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple


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