public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/54801] New: [c++11] static variables constructed with lambda params inside member functions cause undefined errors
@ 2012-10-03 22:28 matt at godbolt dot org
2012-10-04 7:11 ` [Bug c++/54801] " daniel.kruegler at googlemail dot com
` (7 more replies)
0 siblings, 8 replies; 9+ messages in thread
From: matt at godbolt dot org @ 2012-10-03 22:28 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54801
Bug #: 54801
Summary: [c++11] static variables constructed with lambda
params inside member functions cause undefined errors
Classification: Unclassified
Product: gcc
Version: 4.7.2
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: matt@godbolt.org
Created attachment 28346
--> http://gcc.gnu.org/bugzilla/attachment.cgi?id=28346
Test C file exhibiting the issue
In the attached code, there is static method with a static variable whose
constructor takes a function pointer. When a lambda is passed as the function
pointer, it seems the lambda's definition is dropped and the result is a
link-time error.
$ g++ -o test -std=c++0x test.cc
/tmp/ccpBFtG7.o: In function `Test::aFunc()::{lambda(int*)#1}::operator void
(*)(int*)() const':
test.cc:(.text._ZZN4Test5aFuncEvENKUlPiE_cvPFvS0_EEv[_ZZN4Test5aFuncEvENKUlPiE_cvPFvS0_EEv]+0x9):
undefined reference to `Test::aFunc()::{lambda(int*)#1}::_FUN(int*)'
collect2: error: ld returned 1 exit status
Making the variable non-static fixes the issue. The same code in a free
function does not exhibit the problem. Taking a std::function<void(int*)> as
the constructor parameter also cures the issue. It seems to be something which
only throws away the lambda for static variables inside member functions.
More info:
g++ -v
Using built-in specs.
COLLECT_GCC=/site/apps/gcc-4.7.2-drw.patched.1/bin/g++
COLLECT_LTO_WRAPPER=/site/apps/gcc-4.7.2-drw.patched.1/libexec/gcc/x86_64-linux-gnu/4.7.2/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ./configure --prefix /site/apps/gcc-4.7.2-drw.patched.1
--build=x86_64-linux-gnu --enable-clocale=gnu --enable-gold
--enable-languages=c,c++ --enable-ld=default --enable-libstdcxx-debug
--enable-libstdcxx-time=yes --enable-linker-build-id --enable-lto
--enable-plugin --enable-shared --enable-threads=posix --host=x86_64-linux-gnu
--target=x86_64-linux-gnu --with-pkgversion=DRW-internal-build
--with-plugin-ld=ld.gold --with-system-zlib
--with-gmp=/data/teamcity/work/sup-chietfbld02-002/8a981abc13d5c0c5/scratch/gcc/4.7.2/build/gmp-5.0.2
--with-mpfr=/data/teamcity/work/sup-chietfbld02-002/8a981abc13d5c0c5/scratch/gcc/4.7.2/build/mpfr-3.1.1
--with-mpc=/data/teamcity/work/sup-chietfbld02-002/8a981abc13d5c0c5/scratch/gcc/4.7.2/build/mpc-0.9
--with-libelf=/data/teamcity/work/sup-chietfbld02-002/8a981abc13d5c0c5/scratch/gcc/4.7.2/build/libelf-0.8.9
Thread model: posix
gcc version 4.7.2 (DRW-internal-build)
This issue was discovered when attempting to register lambda functions as the
"cleanup function" for static thread-local stored information using
boost::thread_specific_ptr. However, the issue is reproducible in the attached
source file with no external includes.
This appears to be a regression in 4.7.2: gcc versions 4.7.1, 4.7.0, 4.6.3 and
4.5.3 compile the source without issue.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/54801] [c++11] static variables constructed with lambda params inside member functions cause undefined errors
2012-10-03 22:28 [Bug c++/54801] New: [c++11] static variables constructed with lambda params inside member functions cause undefined errors matt at godbolt dot org
@ 2012-10-04 7:11 ` daniel.kruegler at googlemail dot com
2012-10-04 8:41 ` paolo.carlini at oracle dot com
` (6 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: daniel.kruegler at googlemail dot com @ 2012-10-04 7:11 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54801
Daniel Krügler <daniel.kruegler at googlemail dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |daniel.kruegler at
| |googlemail dot com
--- Comment #1 from Daniel Krügler <daniel.kruegler at googlemail dot com> 2012-10-04 07:11:14 UTC ---
Also occurs on gcc 4.8.0 20120930 (experimental).
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/54801] [c++11] static variables constructed with lambda params inside member functions cause undefined errors
2012-10-03 22:28 [Bug c++/54801] New: [c++11] static variables constructed with lambda params inside member functions cause undefined errors matt at godbolt dot org
2012-10-04 7:11 ` [Bug c++/54801] " daniel.kruegler at googlemail dot com
@ 2012-10-04 8:41 ` paolo.carlini at oracle dot com
2012-10-04 9:27 ` [Bug c++/54801] [4.7/4.8 Regression] " paolo.carlini at oracle dot com
` (5 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: paolo.carlini at oracle dot com @ 2012-10-04 8:41 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54801
Paolo Carlini <paolo.carlini at oracle dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Last reconfirmed| |2012-10-04
Blocks| |54367
Ever Confirmed|0 |1
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/54801] [4.7/4.8 Regression] static variables constructed with lambda params inside member functions cause undefined errors
2012-10-03 22:28 [Bug c++/54801] New: [c++11] static variables constructed with lambda params inside member functions cause undefined errors matt at godbolt dot org
2012-10-04 7:11 ` [Bug c++/54801] " daniel.kruegler at googlemail dot com
2012-10-04 8:41 ` paolo.carlini at oracle dot com
@ 2012-10-04 9:27 ` paolo.carlini at oracle dot com
2012-10-04 11:25 ` jakub at gcc dot gnu.org
` (4 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: paolo.carlini at oracle dot com @ 2012-10-04 9:27 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54801
Paolo Carlini <paolo.carlini at oracle dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |hjl.tools at gmail dot com
Summary|[c++11] static variables |[4.7/4.8 Regression] static
|constructed with lambda |variables constructed with
|params inside member |lambda params inside member
|functions cause undefined |functions cause undefined
|errors |errors
--- Comment #2 from Paolo Carlini <paolo.carlini at oracle dot com> 2012-10-04 09:26:55 UTC ---
Confirmed. Maybe H.J can help.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/54801] [4.7/4.8 Regression] static variables constructed with lambda params inside member functions cause undefined errors
2012-10-03 22:28 [Bug c++/54801] New: [c++11] static variables constructed with lambda params inside member functions cause undefined errors matt at godbolt dot org
` (2 preceding siblings ...)
2012-10-04 9:27 ` [Bug c++/54801] [4.7/4.8 Regression] " paolo.carlini at oracle dot com
@ 2012-10-04 11:25 ` jakub at gcc dot gnu.org
2012-10-04 11:41 ` paolo.carlini at oracle dot com
` (3 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: jakub at gcc dot gnu.org @ 2012-10-04 11:25 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54801
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |jakub at gcc dot gnu.org
--- Comment #3 from Jakub Jelinek <jakub at gcc dot gnu.org> 2012-10-04 11:24:46 UTC ---
http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=189175
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/54801] [4.7/4.8 Regression] static variables constructed with lambda params inside member functions cause undefined errors
2012-10-03 22:28 [Bug c++/54801] New: [c++11] static variables constructed with lambda params inside member functions cause undefined errors matt at godbolt dot org
` (3 preceding siblings ...)
2012-10-04 11:25 ` jakub at gcc dot gnu.org
@ 2012-10-04 11:41 ` paolo.carlini at oracle dot com
2012-11-25 15:55 ` rguenth at gcc dot gnu.org
` (2 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: paolo.carlini at oracle dot com @ 2012-10-04 11:41 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54801
Paolo Carlini <paolo.carlini at oracle dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC|hjl.tools at gmail dot com |jason at gcc dot gnu.org
--- Comment #4 from Paolo Carlini <paolo.carlini at oracle dot com> 2012-10-04 11:41:06 UTC ---
Thanks Jakub. Let's add Jason in CC then.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/54801] [4.7/4.8 Regression] static variables constructed with lambda params inside member functions cause undefined errors
2012-10-03 22:28 [Bug c++/54801] New: [c++11] static variables constructed with lambda params inside member functions cause undefined errors matt at godbolt dot org
` (4 preceding siblings ...)
2012-10-04 11:41 ` paolo.carlini at oracle dot com
@ 2012-11-25 15:55 ` rguenth at gcc dot gnu.org
2012-12-03 15:46 ` rguenth at gcc dot gnu.org
2012-12-06 15:45 ` paolo.carlini at oracle dot com
7 siblings, 0 replies; 9+ messages in thread
From: rguenth at gcc dot gnu.org @ 2012-11-25 15:55 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54801
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|--- |4.7.3
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/54801] [4.7/4.8 Regression] static variables constructed with lambda params inside member functions cause undefined errors
2012-10-03 22:28 [Bug c++/54801] New: [c++11] static variables constructed with lambda params inside member functions cause undefined errors matt at godbolt dot org
` (5 preceding siblings ...)
2012-11-25 15:55 ` rguenth at gcc dot gnu.org
@ 2012-12-03 15:46 ` rguenth at gcc dot gnu.org
2012-12-06 15:45 ` paolo.carlini at oracle dot com
7 siblings, 0 replies; 9+ messages in thread
From: rguenth at gcc dot gnu.org @ 2012-12-03 15:46 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54801
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Priority|P3 |P2
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/54801] [4.7/4.8 Regression] static variables constructed with lambda params inside member functions cause undefined errors
2012-10-03 22:28 [Bug c++/54801] New: [c++11] static variables constructed with lambda params inside member functions cause undefined errors matt at godbolt dot org
` (6 preceding siblings ...)
2012-12-03 15:46 ` rguenth at gcc dot gnu.org
@ 2012-12-06 15:45 ` paolo.carlini at oracle dot com
7 siblings, 0 replies; 9+ messages in thread
From: paolo.carlini at oracle dot com @ 2012-12-06 15:45 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54801
Paolo Carlini <paolo.carlini at oracle dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution| |DUPLICATE
--- Comment #5 from Paolo Carlini <paolo.carlini at oracle dot com> 2012-12-06 15:44:50 UTC ---
Dup.
*** This bug has been marked as a duplicate of bug 55015 ***
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2012-12-06 15:45 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-10-03 22:28 [Bug c++/54801] New: [c++11] static variables constructed with lambda params inside member functions cause undefined errors matt at godbolt dot org
2012-10-04 7:11 ` [Bug c++/54801] " daniel.kruegler at googlemail dot com
2012-10-04 8:41 ` paolo.carlini at oracle dot com
2012-10-04 9:27 ` [Bug c++/54801] [4.7/4.8 Regression] " paolo.carlini at oracle dot com
2012-10-04 11:25 ` jakub at gcc dot gnu.org
2012-10-04 11:41 ` paolo.carlini at oracle dot com
2012-11-25 15:55 ` rguenth at gcc dot gnu.org
2012-12-03 15:46 ` rguenth at gcc dot gnu.org
2012-12-06 15:45 ` paolo.carlini at oracle dot com
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).