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:message-id:date:from:mime-version:to:subject :references:in-reply-to:content-type:content-transfer-encoding; q=dns; s=default; b=HgIfUURwGe3+HOKw94lEvXX0Z7hhaqsHlDx9lwK6+w3 WMnwLlktkoFwFq3+vnb2hWAkhLsl1vLCoqSTLu5IfTxPhLkIumU7vrQQQBFpDSvc gXDm2OKUOY3H7u4fmOX8M1cT0z7im408+0r36CgZaCA9HLQoG5NqIu0Of6Be8YEE = 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:message-id:date:from:mime-version:to:subject :references:in-reply-to:content-type:content-transfer-encoding; s=default; bh=ZN3Df7CgVsgl9z64MgNvBQLFdvI=; b=LHFAKNNy+Z/fM//OG jHVfO8dpSHd1IrZAupW5x4T4ZbiLmtc3SSBe2eg6EdqRroccL2qCRznJlTqkH8Tc 6uNxxbai09jsf3+UQdLuNVpY4CdSO1QnJtrXpDJiIXtxSR9CcX6ogYuARTqU/+gQ HgcxjmXp5UudBcSIZl9z/D90mc= Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , 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=-0.1 required=5.0 tests=AWL,BAYES_60,RDNS_NONE,SPF_NEUTRAL,URIBL_BLOCKED autolearn=no version=3.3.2 X-HELO: bureau92.ns.utoronto.ca Message-ID: <5282BBCF.9040703@cs.utoronto.ca> Date: Tue, 12 Nov 2013 18:37:51 -0500 From: Ryan Johnson User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:17.0) Gecko/20130801 Thunderbird/17.0.8 MIME-Version: 1.0 To: cygwin AT cygwin DOT com Subject: Re: C++11 program link failure under GCC 4.8.2-1 References: <52815780 DOT 2010006 AT gmail DOT com> <528159F8 DOT 2070307 AT gmail DOT com> <5281F8D4 DOT 4090809 AT gmail DOT com> <5282ABED DOT 7040400 AT gmail DOT com> In-Reply-To: <5282ABED.7040400@gmail.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-IsSubscribed: yes On 12/11/2013 5:30 PM, JonY wrote: > On 11/13/2013 02:35, Yucong Sun wrote: >> Good new! I've found the link failure issue, it is caused by "-rdynamic" >> >> sunyc AT sunyc-wks ~ >> $ cat 2.cc >> #include >> >> struct tick_event { >> int i; >> }; >> >> int main() { >> std::deque list; >> >> tick_event *a = new tick_event; >> list.push_back(a); >> return 0; >> } >> >> sunyc AT sunyc-wks ~ >> $ g++ -c --std=c++11 -O3 -flto 2.cc -o 2.o >> >> sunyc AT sunyc-wks ~ >> $ g++ --std=c++11 -flto -D_GNU_SOURCE -rdynamic -fno-omit-frame-pointer -D_GNU_ >> SOURCE -march=native -O3 2.o -o a >> Cannot export _ZNSt5dequeIP10tick_eventSaIS1_EE16_M_push_back_auxIJRKS1_EEEvDpOT >> _: symbol wrong type (4 vs 3) >> collect2: error: ld returned 1 exit status >> >> >> sunyc AT sunyc-wks ~ >> $ g++ --std=c++11 -flto -D_GNU_SOURCE -fno-omit-frame-pointer -D_GNU_SOURCE -ma >> rch=native -O3 2.o -o a >> >> sunyc AT sunyc-wks ~ >> $ >> >> Hope it would help you nail the problem. >> > -rdynamic shouldn't do anything on Windows, I guess using ELF specific > arguments can break things. >> And Here's the test case for snprintf & c++11 >> >> $ gcc -v >> Using built-in specs. >> COLLECT_GCC=gcc >> COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-pc-cygwin/4.8.2/lto-wrapper.exe >> Target: x86_64-pc-cygwin >> Configured with: /cygdrive/i/szsz/tmpp/cygwin64/gcc/gcc-4.8.2-1/src/gcc-4.8.2/co >> nfigure --srcdir=/cygdrive/i/szsz/tmpp/cygwin64/gcc/gcc-4.8.2-1/src/gcc-4.8.2 -- >> prefix=/usr --exec-prefix=/usr --bindir=/usr/bin --sbindir=/usr/sbin --libexecdi >> r=/usr/libexec --datadir=/usr/share --localstatedir=/var --sysconfdir=/etc --lib >> dir=/usr/lib --datarootdir=/usr/share --docdir=/usr/share/doc/gcc -C --build=x86 >> _64-pc-cygwin --host=x86_64-pc-cygwin --target=x86_64-pc-cygwin --without-libico >> nv-prefix --without-libintl-prefix --enable-shared --enable-shared-libgcc --enab >> le-static --enable-version-specific-runtime-libs --enable-bootstrap --disable-__ >> cxa_atexit --with-dwarf2 --with-tune=generic --enable-languages=c,c++,fortran,lt >> o,objc,obj-c++ --enable-graphite --enable-threads=posix --enable-libatomic --ena >> ble-libgomp --disable-libitm --enable-libquadmath --enable-libquadmath-support - >> -enable-libssp --enable-libgcj-sublibs --disable-java-awt --disable-symvers --wi >> th-ecj-jar=/usr/share/java/ecj.jar --with-gnu-ld --with-gnu-as --with-cloog-incl >> ude=/usr/include/cloog-isl --without-libiconv-prefix --without-libintl-prefix -- >> with-system-zlib >> Thread model: posix >> gcc version 4.8.2 (GCC) >> >> >> sunyc AT sunyc-wks ~ >> $ cat 1.cc >> #include >> >> int main() { >> char out[255]; >> snprintf(out, sizeof(out), "%d", 1); >> return 1; >> } >> >> sunyc AT sunyc-wks ~ >> $ g++ --std=c++11 1.cc >> 1.cc: In function ‘int main()’: >> 1.cc:5:36: error: ‘snprintf’ was not declared in this scope >> snprintf(out, sizeof(out), "%d", 1); >> ^ >> >> sunyc AT sunyc-wks ~ >> $ g++ --std=gnu++0x 1.cc >> >> sunyc AT sunyc-wks ~ >> $ ls -lah a.exe >> -rwxr-xr-x 1 sunyc None 62K Nov 12 10:21 a.exe >> >> Cheers. >> > Right now, it is guarded by: > #if !defined(__STRICT_ANSI__) || (__STDC_VERSION__ >= 199901L) > > Which means non-strict mode and C99 mode, snprintf was not part of > C++03. I guess (__cplusplus >= 201103L) needs to be added to newlib. Yes, this has come up before [1]. Several *printf variants are affected IIRC. [1] http://cygwin.com/ml/cygwin/2012-04/msg00140.html Ryan -- 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