public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* g++-5.2.0 miscompiles a simple program
@ 2015-12-12 14:49 Piotr Mitas
  2015-12-13  4:11 ` JonY
  0 siblings, 1 reply; 2+ messages in thread
From: Piotr Mitas @ 2015-12-12 14:49 UTC (permalink / raw)
  To: cygwin

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: g++-5.2.0 miscompiles a simple program
  2015-12-12 14:49 g++-5.2.0 miscompiles a simple program Piotr Mitas
@ 2015-12-13  4:11 ` JonY
  0 siblings, 0 replies; 2+ messages in thread
From: JonY @ 2015-12-13  4:11 UTC (permalink / raw)
  To: cygwin

[-- Attachment #1: Type: text/plain, Size: 216 bytes --]

On 12/12/2015 22:49, Piotr Mitas wrote:
> g++-5.2.0 miscompiles the following program so badly, that gdb can't
> even break at the exe's entry point.

Make sure you have also selected all the 5.2 runtime.




[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 801 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-12-13  4:11 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-12-12 14:49 g++-5.2.0 miscompiles a simple program Piotr Mitas
2015-12-13  4:11 ` JonY

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).