delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2015/12/12/09:49:53

X-Recipient: archive-cygwin AT delorie DOT com
DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id
:list-unsubscribe:list-subscribe:list-archive:list-post
:list-help:sender:mime-version:date:message-id:subject:from:to
:content-type; q=dns; s=default; b=d3lRHkEWWykjIj+299CNki1Exbduh
ab93PTFW6R/QQ5v2gGrcgfnB8uId4PEBzFyEgWgc3+MOCga5r4pV1r9Tu3ijKOvh
9bsqNIA/5rJtru7QX9B6WH+XqKRLzBoKJ7cdYiEt4gL/zWnFf4mswbxqY/CJIOSx
ML+mdIPZp6AcpM=
DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id
:list-unsubscribe:list-subscribe:list-archive:list-post
:list-help:sender:mime-version:date:message-id:subject:from:to
:content-type; s=default; bh=1mJCyTYlQkrVsGoA8jwlEi702XU=; b=O9V
RRlmx2fHZb8tm+q+RTG78nOZI1VAr/mW1CeWUf+d4OlA0m4M8dMd1UoQeY7jclJN
ha/1jMp64Fg7k3fy8xh1AzyWTOW65xczJwRVigvNU9xpSYfwXqt17larZ7/y9/tT
RAyZ0XP0CS5HitOOeIcpGiXzEJVPL45gCqway82A=
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
Authentication-Results: sourceware.org; auth=none
X-Virus-Found: No
X-Spam-SWARE-Status: No, score=-2.6 required=5.0 tests=BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2
X-HELO: mail-ig0-f169.google.com
MIME-Version: 1.0
X-Received: by 10.50.153.69 with SMTP id ve5mr9153891igb.80.1449931771494; Sat, 12 Dec 2015 06:49:31 -0800 (PST)
Date: Sat, 12 Dec 2015 15:49:31 +0100
Message-ID: <CAFeZVJLxKMAU7noFNYBjF1OwP6QEgwEsuvOYtepro_m8R+7R9Q@mail.gmail.com>
Subject: g++-5.2.0 miscompiles a simple program
From: Piotr Mitas <mitaspiotr AT gmail DOT com>
To: cygwin AT cygwin DOT com

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

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019