public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/55015] New: Lambda functions not found at link time when declared in an inline function
@ 2012-10-22 2:10 julien.nitard at m4tp dot org
2012-10-22 2:14 ` [Bug c++/55015] " julien.nitard at m4tp dot org
` (15 more replies)
0 siblings, 16 replies; 17+ messages in thread
From: julien.nitard at m4tp dot org @ 2012-10-22 2:10 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55015
Bug #: 55015
Summary: Lambda functions not found at link time when declared
in an inline function
Classification: Unclassified
Product: gcc
Version: 4.7.2
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: julien.nitard@m4tp.org
Hi all,
Following this stackoverflow question
http://stackoverflow.com/questions/13003941/lambda-not-found-when-defined-in-an-inline-function-in-g-4-7,
I was directed here to report a bug.
I have tried to find similar bugs but haven't.
Lambdas are not handled properly when declared inside inline functions (or so
it seems).
Here is a LWS link that demonstrates the error:
http://liveworkspace.org/code/35374b3c9b0d40e8ccc0819eb44d7f9e
In case the link disappears, here the source:
#include <stdexcept>
#include <string>
#include <boost/algorithm/string.hpp>
using std::string;
typedef bool (*FieldComparer)(const std::string&, const std::string&);
inline FieldComparer
GetComparer(const std::string& query, string& separator)
{
if (query.find('=') != std::string::npos) {
separator = "=";
return [](const string& s1, const string& s2) { return s1 == s2; };
}
else if (query.find('^') != string::npos) {
separator = "^";
return [](const string& s1, const string& s2) { return
boost::starts_with(s1, s2); };
}
else if (query.find('*') != string::npos) {
separator = "*";
return [](const string& s1, const string& s2) { return
boost::contains(s1, s2); };
}
else if (query.find('!') != string::npos) {
separator = "!";
return [](const string& s1, const string& s2) { return s1 != s2; };
}
else
throw std::invalid_argument("Search: could not find operator in query
string.");
}
int main()
{
std::string sep;
auto comp = GetComparer( "=", sep );
}
Many thanks,
^ permalink raw reply [flat|nested] 17+ messages in thread
* [Bug c++/55015] Lambda functions not found at link time when declared in an inline function
2012-10-22 2:10 [Bug c++/55015] New: Lambda functions not found at link time when declared in an inline function julien.nitard at m4tp dot org
@ 2012-10-22 2:14 ` julien.nitard at m4tp dot org
2012-10-22 5:02 ` spam_hole at shaw dot ca
` (14 subsequent siblings)
15 siblings, 0 replies; 17+ messages in thread
From: julien.nitard at m4tp dot org @ 2012-10-22 2:14 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55015
--- Comment #1 from Julien Nitard <julien.nitard at m4tp dot org> 2012-10-22 02:13:43 UTC ---
Somebody noted in S.O. that declaring the inline function "static" (or using an
anonymous namespace which I guess as same effect) hides (or solves ;) the
problem.
^ permalink raw reply [flat|nested] 17+ messages in thread
* [Bug c++/55015] Lambda functions not found at link time when declared in an inline function
2012-10-22 2:10 [Bug c++/55015] New: Lambda functions not found at link time when declared in an inline function julien.nitard at m4tp dot org
2012-10-22 2:14 ` [Bug c++/55015] " julien.nitard at m4tp dot org
@ 2012-10-22 5:02 ` spam_hole at shaw dot ca
2012-10-22 5:09 ` pinskia at gcc dot gnu.org
` (13 subsequent siblings)
15 siblings, 0 replies; 17+ messages in thread
From: spam_hole at shaw dot ca @ 2012-10-22 5:02 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55015
Robert Xiao <spam_hole at shaw dot ca> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |spam_hole at shaw dot ca
--- Comment #2 from Robert Xiao <spam_hole at shaw dot ca> 2012-10-22 05:02:01 UTC ---
Minimal reproducible testcase:
typedef void (*VoidFunc)();
inline VoidFunc GetFunc() { return [](){}; }
int main() { VoidFunc func = GetFunc(); }
Compiled with gcc version 4.7.2 (MacPorts gcc47 4.7.2_2). Output:
$ g++-mp-4.7 test.cpp -std=c++11
Undefined symbols for architecture x86_64:
"GetFunc()::{lambda()#1}::_FUN()", referenced from:
GetFunc()::{lambda()#1}::operator void (*)()() const in cciEeUag.o
ld: symbol(s) not found for architecture x86_64
collect2: error: ld returned 1 exit status
^ permalink raw reply [flat|nested] 17+ messages in thread
* [Bug c++/55015] Lambda functions not found at link time when declared in an inline function
2012-10-22 2:10 [Bug c++/55015] New: Lambda functions not found at link time when declared in an inline function julien.nitard at m4tp dot org
2012-10-22 2:14 ` [Bug c++/55015] " julien.nitard at m4tp dot org
2012-10-22 5:02 ` spam_hole at shaw dot ca
@ 2012-10-22 5:09 ` pinskia at gcc dot gnu.org
2012-11-02 11:11 ` paolo.carlini at oracle dot com
` (12 subsequent siblings)
15 siblings, 0 replies; 17+ messages in thread
From: pinskia at gcc dot gnu.org @ 2012-10-22 5:09 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55015
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |assemble-failure
Status|UNCONFIRMED |NEW
Last reconfirmed| |2012-10-22
CC| |pinskia at gcc dot gnu.org
Ever Confirmed|0 |1
--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> 2012-10-22 05:09:36 UTC ---
Confirmed on the trunk too.
^ permalink raw reply [flat|nested] 17+ messages in thread
* [Bug c++/55015] Lambda functions not found at link time when declared in an inline function
2012-10-22 2:10 [Bug c++/55015] New: Lambda functions not found at link time when declared in an inline function julien.nitard at m4tp dot org
` (2 preceding siblings ...)
2012-10-22 5:09 ` pinskia at gcc dot gnu.org
@ 2012-11-02 11:11 ` paolo.carlini at oracle dot com
2012-11-26 23:38 ` [Bug c++/55015] [4.7/4.8 Regression] " paolo.carlini at oracle dot com
` (11 subsequent siblings)
15 siblings, 0 replies; 17+ messages in thread
From: paolo.carlini at oracle dot com @ 2012-11-02 11:11 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55015
Paolo Carlini <paolo.carlini at oracle dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |icegood1980 at gmail dot
| |com
--- Comment #4 from Paolo Carlini <paolo.carlini at oracle dot com> 2012-11-02 11:10:49 UTC ---
*** Bug 55178 has been marked as a duplicate of this bug. ***
^ permalink raw reply [flat|nested] 17+ messages in thread
* [Bug c++/55015] [4.7/4.8 Regression] Lambda functions not found at link time when declared in an inline function
2012-10-22 2:10 [Bug c++/55015] New: Lambda functions not found at link time when declared in an inline function julien.nitard at m4tp dot org
` (3 preceding siblings ...)
2012-11-02 11:11 ` paolo.carlini at oracle dot com
@ 2012-11-26 23:38 ` paolo.carlini at oracle dot com
2012-11-27 10:26 ` paolo.carlini at oracle dot com
` (10 subsequent siblings)
15 siblings, 0 replies; 17+ messages in thread
From: paolo.carlini at oracle dot com @ 2012-11-26 23:38 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55015
Paolo Carlini <paolo.carlini at oracle dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Summary|Lambda functions not found |[4.7/4.8 Regression] Lambda
|at link time when declared |functions not found at link
|in an inline function |time when declared in an
| |inline function
--- Comment #5 from Paolo Carlini <paolo.carlini at oracle dot com> 2012-11-26 23:37:48 UTC ---
This is a regression.
^ permalink raw reply [flat|nested] 17+ messages in thread
* [Bug c++/55015] [4.7/4.8 Regression] Lambda functions not found at link time when declared in an inline function
2012-10-22 2:10 [Bug c++/55015] New: Lambda functions not found at link time when declared in an inline function julien.nitard at m4tp dot org
` (4 preceding siblings ...)
2012-11-26 23:38 ` [Bug c++/55015] [4.7/4.8 Regression] " paolo.carlini at oracle dot com
@ 2012-11-27 10:26 ` paolo.carlini at oracle dot com
2012-11-27 11:01 ` jakub at gcc dot gnu.org
` (9 subsequent siblings)
15 siblings, 0 replies; 17+ messages in thread
From: paolo.carlini at oracle dot com @ 2012-11-27 10:26 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55015
Paolo Carlini <paolo.carlini at oracle dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |hjl.tools at gmail dot com
--- Comment #6 from Paolo Carlini <paolo.carlini at oracle dot com> 2012-11-27 10:26:03 UTC ---
HJ, can you help finding which change broke this? In Comment #2 there is a very
short testcase (it's pretty old, I guess you want -std=c++0x, not -std=c++11 in
the command line)
^ permalink raw reply [flat|nested] 17+ messages in thread
* [Bug c++/55015] [4.7/4.8 Regression] Lambda functions not found at link time when declared in an inline function
2012-10-22 2:10 [Bug c++/55015] New: Lambda functions not found at link time when declared in an inline function julien.nitard at m4tp dot org
` (5 preceding siblings ...)
2012-11-27 10:26 ` paolo.carlini at oracle dot com
@ 2012-11-27 11:01 ` jakub at gcc dot gnu.org
2012-11-27 11:03 ` paolo.carlini at oracle dot com
` (8 subsequent siblings)
15 siblings, 0 replies; 17+ messages in thread
From: jakub at gcc dot gnu.org @ 2012-11-27 11:01 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55015
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |jakub at gcc dot gnu.org
Target Milestone|--- |4.8.0
--- Comment #7 from Jakub Jelinek <jakub at gcc dot gnu.org> 2012-11-27 11:00:54 UTC ---
http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=189175
^ permalink raw reply [flat|nested] 17+ messages in thread
* [Bug c++/55015] [4.7/4.8 Regression] Lambda functions not found at link time when declared in an inline function
2012-10-22 2:10 [Bug c++/55015] New: Lambda functions not found at link time when declared in an inline function julien.nitard at m4tp dot org
` (6 preceding siblings ...)
2012-11-27 11:01 ` jakub at gcc dot gnu.org
@ 2012-11-27 11:03 ` paolo.carlini at oracle dot com
2012-11-27 11:04 ` paolo.carlini at oracle dot com
` (7 subsequent siblings)
15 siblings, 0 replies; 17+ messages in thread
From: paolo.carlini at oracle dot com @ 2012-11-27 11:03 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55015
--- Comment #8 from Paolo Carlini <paolo.carlini at oracle dot com> 2012-11-27 11:02:42 UTC ---
Never mind, it's very easy, it's the following change, the fix for PR53821:
http://gcc.gnu.org/viewcvs?view=revision&revision=189176
And PR55472 is a duplicate, reverting the above fixes it too.
^ permalink raw reply [flat|nested] 17+ messages in thread
* [Bug c++/55015] [4.7/4.8 Regression] Lambda functions not found at link time when declared in an inline function
2012-10-22 2:10 [Bug c++/55015] New: Lambda functions not found at link time when declared in an inline function julien.nitard at m4tp dot org
` (7 preceding siblings ...)
2012-11-27 11:03 ` paolo.carlini at oracle dot com
@ 2012-11-27 11:04 ` paolo.carlini at oracle dot com
2012-12-03 16:01 ` rguenth at gcc dot gnu.org
` (6 subsequent siblings)
15 siblings, 0 replies; 17+ messages in thread
From: paolo.carlini at oracle dot com @ 2012-11-27 11:04 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55015
Paolo Carlini <paolo.carlini at oracle dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |walker_643 at yahoo dot com
--- Comment #9 from Paolo Carlini <paolo.carlini at oracle dot com> 2012-11-27 11:03:54 UTC ---
*** Bug 55472 has been marked as a duplicate of this bug. ***
^ permalink raw reply [flat|nested] 17+ messages in thread
* [Bug c++/55015] [4.7/4.8 Regression] Lambda functions not found at link time when declared in an inline function
2012-10-22 2:10 [Bug c++/55015] New: Lambda functions not found at link time when declared in an inline function julien.nitard at m4tp dot org
` (8 preceding siblings ...)
2012-11-27 11:04 ` paolo.carlini at oracle dot com
@ 2012-12-03 16:01 ` rguenth at gcc dot gnu.org
2012-12-05 22:35 ` jason at gcc dot gnu.org
` (5 subsequent siblings)
15 siblings, 0 replies; 17+ messages in thread
From: rguenth at gcc dot gnu.org @ 2012-12-03 16:01 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55015
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Priority|P3 |P2
^ permalink raw reply [flat|nested] 17+ messages in thread
* [Bug c++/55015] [4.7/4.8 Regression] Lambda functions not found at link time when declared in an inline function
2012-10-22 2:10 [Bug c++/55015] New: Lambda functions not found at link time when declared in an inline function julien.nitard at m4tp dot org
` (9 preceding siblings ...)
2012-12-03 16:01 ` rguenth at gcc dot gnu.org
@ 2012-12-05 22:35 ` jason at gcc dot gnu.org
2012-12-06 11:32 ` paolo.carlini at oracle dot com
` (4 subsequent siblings)
15 siblings, 0 replies; 17+ messages in thread
From: jason at gcc dot gnu.org @ 2012-12-05 22:35 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55015
Jason Merrill <jason at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |ASSIGNED
CC| |jason at gcc dot gnu.org
AssignedTo|unassigned at gcc dot |jason at gcc dot gnu.org
|gnu.org |
^ permalink raw reply [flat|nested] 17+ messages in thread
* [Bug c++/55015] [4.7/4.8 Regression] Lambda functions not found at link time when declared in an inline function
2012-10-22 2:10 [Bug c++/55015] New: Lambda functions not found at link time when declared in an inline function julien.nitard at m4tp dot org
` (10 preceding siblings ...)
2012-12-05 22:35 ` jason at gcc dot gnu.org
@ 2012-12-06 11:32 ` paolo.carlini at oracle dot com
2012-12-06 14:38 ` jason at gcc dot gnu.org
` (3 subsequent siblings)
15 siblings, 0 replies; 17+ messages in thread
From: paolo.carlini at oracle dot com @ 2012-12-06 11:32 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55015
Paolo Carlini <paolo.carlini at oracle dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |f.heckenbach@fh-soft.de
--- Comment #10 from Paolo Carlini <paolo.carlini at oracle dot com> 2012-12-06 11:32:25 UTC ---
*** Bug 55607 has been marked as a duplicate of this bug. ***
^ permalink raw reply [flat|nested] 17+ messages in thread
* [Bug c++/55015] [4.7/4.8 Regression] Lambda functions not found at link time when declared in an inline function
2012-10-22 2:10 [Bug c++/55015] New: Lambda functions not found at link time when declared in an inline function julien.nitard at m4tp dot org
` (11 preceding siblings ...)
2012-12-06 11:32 ` paolo.carlini at oracle dot com
@ 2012-12-06 14:38 ` jason at gcc dot gnu.org
2012-12-06 14:40 ` jason at gcc dot gnu.org
` (2 subsequent siblings)
15 siblings, 0 replies; 17+ messages in thread
From: jason at gcc dot gnu.org @ 2012-12-06 14:38 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55015
--- Comment #11 from Jason Merrill <jason at gcc dot gnu.org> 2012-12-06 14:37:23 UTC ---
Author: jason
Date: Thu Dec 6 14:37:13 2012
New Revision: 194251
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=194251
Log:
PR c++/55015
PR c++/53821
* semantics.c (maybe_add_lambda_conv_op): Revert earlier change.
* decl.c (start_preparsed_function): Make local class methods comdat
in templates, too.
Added:
trunk/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-conv6.C
Modified:
trunk/gcc/cp/ChangeLog
trunk/gcc/cp/decl.c
trunk/gcc/cp/semantics.c
^ permalink raw reply [flat|nested] 17+ messages in thread
* [Bug c++/55015] [4.7/4.8 Regression] Lambda functions not found at link time when declared in an inline function
2012-10-22 2:10 [Bug c++/55015] New: Lambda functions not found at link time when declared in an inline function julien.nitard at m4tp dot org
` (12 preceding siblings ...)
2012-12-06 14:38 ` jason at gcc dot gnu.org
@ 2012-12-06 14:40 ` jason at gcc dot gnu.org
2012-12-06 14:43 ` jason at gcc dot gnu.org
2012-12-06 15:45 ` paolo.carlini at oracle dot com
15 siblings, 0 replies; 17+ messages in thread
From: jason at gcc dot gnu.org @ 2012-12-06 14:40 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55015
--- Comment #12 from Jason Merrill <jason at gcc dot gnu.org> 2012-12-06 14:39:57 UTC ---
Author: jason
Date: Thu Dec 6 14:39:52 2012
New Revision: 194253
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=194253
Log:
PR c++/55015
PR c++/53821
* semantics.c (maybe_add_lambda_conv_op): Revert earlier change.
* decl.c (start_preparsed_function): Make local class methods comdat
in templates, too.
Added:
branches/gcc-4_7-branch/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-conv6.C
Modified:
branches/gcc-4_7-branch/gcc/cp/ChangeLog
branches/gcc-4_7-branch/gcc/cp/decl.c
branches/gcc-4_7-branch/gcc/cp/semantics.c
^ permalink raw reply [flat|nested] 17+ messages in thread
* [Bug c++/55015] [4.7/4.8 Regression] Lambda functions not found at link time when declared in an inline function
2012-10-22 2:10 [Bug c++/55015] New: Lambda functions not found at link time when declared in an inline function julien.nitard at m4tp dot org
` (13 preceding siblings ...)
2012-12-06 14:40 ` jason at gcc dot gnu.org
@ 2012-12-06 14:43 ` jason at gcc dot gnu.org
2012-12-06 15:45 ` paolo.carlini at oracle dot com
15 siblings, 0 replies; 17+ messages in thread
From: jason at gcc dot gnu.org @ 2012-12-06 14:43 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55015
Jason Merrill <jason at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Resolution| |FIXED
Target Milestone|4.8.0 |4.7.3
--- Comment #13 from Jason Merrill <jason at gcc dot gnu.org> 2012-12-06 14:42:45 UTC ---
Fixed for 4.7.3.
^ permalink raw reply [flat|nested] 17+ messages in thread
* [Bug c++/55015] [4.7/4.8 Regression] Lambda functions not found at link time when declared in an inline function
2012-10-22 2:10 [Bug c++/55015] New: Lambda functions not found at link time when declared in an inline function julien.nitard at m4tp dot org
` (14 preceding siblings ...)
2012-12-06 14:43 ` jason at gcc dot gnu.org
@ 2012-12-06 15:45 ` paolo.carlini at oracle dot com
15 siblings, 0 replies; 17+ 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=55015
Paolo Carlini <paolo.carlini at oracle dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |matt at godbolt dot org
--- Comment #14 from Paolo Carlini <paolo.carlini at oracle dot com> 2012-12-06 15:44:50 UTC ---
*** Bug 54801 has been marked as a duplicate of this bug. ***
^ permalink raw reply [flat|nested] 17+ messages in thread
end of thread, other threads:[~2012-12-06 15:45 UTC | newest]
Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-10-22 2:10 [Bug c++/55015] New: Lambda functions not found at link time when declared in an inline function julien.nitard at m4tp dot org
2012-10-22 2:14 ` [Bug c++/55015] " julien.nitard at m4tp dot org
2012-10-22 5:02 ` spam_hole at shaw dot ca
2012-10-22 5:09 ` pinskia at gcc dot gnu.org
2012-11-02 11:11 ` paolo.carlini at oracle dot com
2012-11-26 23:38 ` [Bug c++/55015] [4.7/4.8 Regression] " paolo.carlini at oracle dot com
2012-11-27 10:26 ` paolo.carlini at oracle dot com
2012-11-27 11:01 ` jakub at gcc dot gnu.org
2012-11-27 11:03 ` paolo.carlini at oracle dot com
2012-11-27 11:04 ` paolo.carlini at oracle dot com
2012-12-03 16:01 ` rguenth at gcc dot gnu.org
2012-12-05 22:35 ` jason at gcc dot gnu.org
2012-12-06 11:32 ` paolo.carlini at oracle dot com
2012-12-06 14:38 ` jason at gcc dot gnu.org
2012-12-06 14:40 ` jason at gcc dot gnu.org
2012-12-06 14:43 ` jason 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).