public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/55710] New: [C++11] Linkage errors with lambdas
@ 2012-12-15 17:11 daniel.kruegler at googlemail dot com
  2012-12-15 18:29 ` [Bug c++/55710] " pinskia at gcc dot gnu.org
                   ` (11 more replies)
  0 siblings, 12 replies; 13+ messages in thread
From: daniel.kruegler at googlemail dot com @ 2012-12-15 17:11 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55710

             Bug #: 55710
           Summary: [C++11] Linkage errors with lambdas
    Classification: Unclassified
           Product: gcc
           Version: 4.8.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: daniel.kruegler@googlemail.com


The following program compiled with gcc 4.8.0 20121209 (experimental) and
compiled with flags

-Wall -std=c++11 -pedantic

//----------------
template <class T>
struct X {
  static void (*code) ();
};

template <class T>
void (*X<T>::code) () = []{};  // Line 7

struct Y {
  void (*code) () = []{} ; // Line 10
  void operator()() { code(); }
};

int main () {
  X<int>::code();
  Y()();
}
//----------------

gives two linkage errors:

"|In function `Y::code::{lambda()#1}::operator void (*)()() const':|
10|undefined reference to `Y::code::{lambda()#1}::_FUN()'|
|In function `X<int>::code::{lambda()#1}::operator void (*)()() const':|
7|undefined reference to `X<int>::code::{lambda()#1}::_FUN()'|
"

for the functions that should be defined for the corresponding uncaptured
lambda expressions.

It should be noted, that

struct Z {
  static void (*code) ();
};

void (*Z::code) () = []{};

int main () {
  Z::code();
}

doesn't cause a similar linkage error, though.


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

* [Bug c++/55710] [C++11] Linkage errors with lambdas
  2012-12-15 17:11 [Bug c++/55710] New: [C++11] Linkage errors with lambdas daniel.kruegler at googlemail dot com
@ 2012-12-15 18:29 ` pinskia at gcc dot gnu.org
  2012-12-15 18:52 ` paolo.carlini at oracle dot com
                   ` (10 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: pinskia at gcc dot gnu.org @ 2012-12-15 18:29 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55710

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> 2012-12-15 18:29:33 UTC ---
Related to PR 55015.


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

* [Bug c++/55710] [C++11] Linkage errors with lambdas
  2012-12-15 17:11 [Bug c++/55710] New: [C++11] Linkage errors with lambdas daniel.kruegler at googlemail dot com
  2012-12-15 18:29 ` [Bug c++/55710] " pinskia at gcc dot gnu.org
@ 2012-12-15 18:52 ` paolo.carlini at oracle dot com
  2012-12-15 18:58 ` daniel.kruegler at googlemail dot com
                   ` (9 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: paolo.carlini at oracle dot com @ 2012-12-15 18:52 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55710

Paolo Carlini <paolo.carlini at oracle dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2012-12-15
     Ever Confirmed|0                           |1

--- Comment #2 from Paolo Carlini <paolo.carlini at oracle dot com> 2012-12-15 18:51:58 UTC ---
As-is, at variance with PR 55015, this can't be a regression in mainline and
4.7.x, because 4.6.x didn't have non-static data member initializers. If Daniel
can figure out something similar not-using NSDMI which worked in 4.6.x, it's
much more likely to be fixed for 4.8.0.


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

* [Bug c++/55710] [C++11] Linkage errors with lambdas
  2012-12-15 17:11 [Bug c++/55710] New: [C++11] Linkage errors with lambdas daniel.kruegler at googlemail dot com
  2012-12-15 18:29 ` [Bug c++/55710] " pinskia at gcc dot gnu.org
  2012-12-15 18:52 ` paolo.carlini at oracle dot com
@ 2012-12-15 18:58 ` daniel.kruegler at googlemail dot com
  2012-12-15 19:03 ` paolo.carlini at oracle dot com
                   ` (8 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: daniel.kruegler at googlemail dot com @ 2012-12-15 18:58 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55710

--- Comment #3 from Daniel Krügler <daniel.kruegler at googlemail dot com> 2012-12-15 18:57:37 UTC ---
(In reply to comment #2)
Note that my first example is not related to NSDMIs, it occurs in a static data
member initializer.

The actual reason for understanding the possible reasons for such an error is
because we stumbled across it in an - unfortunately very complex - production
code. Backed with the reference to bug 55015 I try to check that with our
actual code on Monday.


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

* [Bug c++/55710] [C++11] Linkage errors with lambdas
  2012-12-15 17:11 [Bug c++/55710] New: [C++11] Linkage errors with lambdas daniel.kruegler at googlemail dot com
                   ` (2 preceding siblings ...)
  2012-12-15 18:58 ` daniel.kruegler at googlemail dot com
@ 2012-12-15 19:03 ` paolo.carlini at oracle dot com
  2012-12-15 19:07 ` paolo.carlini at oracle dot com
                   ` (7 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: paolo.carlini at oracle dot com @ 2012-12-15 19:03 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55710

--- Comment #4 from Paolo Carlini <paolo.carlini at oracle dot com> 2012-12-15 19:03:10 UTC ---
Oops, 4.6.x says that NSDMIs are needed for line 10 and rejects it, that misled
me. Then, what can I say, probably the issue isn't a regression and it's only
superficially similar to PR 55015 (which is already fixed)


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

* [Bug c++/55710] [C++11] Linkage errors with lambdas
  2012-12-15 17:11 [Bug c++/55710] New: [C++11] Linkage errors with lambdas daniel.kruegler at googlemail dot com
                   ` (3 preceding siblings ...)
  2012-12-15 19:03 ` paolo.carlini at oracle dot com
@ 2012-12-15 19:07 ` paolo.carlini at oracle dot com
  2012-12-15 19:56 ` daniel.kruegler at googlemail dot com
                   ` (6 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: paolo.carlini at oracle dot com @ 2012-12-15 19:07 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55710

--- Comment #5 from Paolo Carlini <paolo.carlini at oracle dot com> 2012-12-15 19:07:34 UTC ---
To repeat: in order to, so to speak, raise the priority of this issue, we need
a testcase which was accepted by 4.6.x (or 4.7.x): the testcase we have got
isn't Ok for that, because 4.6.x rejects it immediately, that is at
compile-time, line #10.


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

* [Bug c++/55710] [C++11] Linkage errors with lambdas
  2012-12-15 17:11 [Bug c++/55710] New: [C++11] Linkage errors with lambdas daniel.kruegler at googlemail dot com
                   ` (4 preceding siblings ...)
  2012-12-15 19:07 ` paolo.carlini at oracle dot com
@ 2012-12-15 19:56 ` daniel.kruegler at googlemail dot com
  2012-12-17 13:55 ` daniel.kruegler at googlemail dot com
                   ` (5 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: daniel.kruegler at googlemail dot com @ 2012-12-15 19:56 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55710

--- Comment #6 from Daniel Krügler <daniel.kruegler at googlemail dot com> 2012-12-15 19:55:56 UTC ---
(In reply to comment #5)
So will the following do that:

//----------------
template <class T>
struct X {
  static void (*code) ();
};

template <class T>
void (*X<T>::code) () = []{};  // Line 7

int main () {
  X<int>::code();
}
//----------------

giving me

"In function `X<int>::code::{lambda()#1}::operator void (*)()() const':|
|7|undefined reference to `X<int>::code::{lambda()#1}::_FUN()'|
"

?


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

* [Bug c++/55710] [C++11] Linkage errors with lambdas
  2012-12-15 17:11 [Bug c++/55710] New: [C++11] Linkage errors with lambdas daniel.kruegler at googlemail dot com
                   ` (5 preceding siblings ...)
  2012-12-15 19:56 ` daniel.kruegler at googlemail dot com
@ 2012-12-17 13:55 ` daniel.kruegler at googlemail dot com
  2012-12-19 18:03 ` paolo.carlini at oracle dot com
                   ` (4 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: daniel.kruegler at googlemail dot com @ 2012-12-17 13:55 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55710

--- Comment #7 from Daniel Krügler <daniel.kruegler at googlemail dot com> 2012-12-17 13:54:20 UTC ---
(In reply to comment #3)
I have now much confidence that our production code (based on GCC 4.7.2) fails
due to bug 55015. Fortunately there is a known workaround for that one.

To make resolving this issue here easier, I will split-off the GCC 4.6.x-only
part as a separate issue.


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

* [Bug c++/55710] [C++11] Linkage errors with lambdas
  2012-12-15 17:11 [Bug c++/55710] New: [C++11] Linkage errors with lambdas daniel.kruegler at googlemail dot com
                   ` (6 preceding siblings ...)
  2012-12-17 13:55 ` daniel.kruegler at googlemail dot com
@ 2012-12-19 18:03 ` paolo.carlini at oracle dot com
  2013-02-13 18:16 ` jason at gcc dot gnu.org
                   ` (3 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: paolo.carlini at oracle dot com @ 2012-12-19 18:03 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55710

--- Comment #8 from Paolo Carlini <paolo.carlini at oracle dot com> 2012-12-19 18:03:23 UTC ---
Thanks Daniel for the new testcase in Comment #6. I'm afraid however we still
don't have a regression, because the testcase compiles but doesn't link in
4.6.x too.


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

* [Bug c++/55710] [C++11] Linkage errors with lambdas
  2012-12-15 17:11 [Bug c++/55710] New: [C++11] Linkage errors with lambdas daniel.kruegler at googlemail dot com
                   ` (7 preceding siblings ...)
  2012-12-19 18:03 ` paolo.carlini at oracle dot com
@ 2013-02-13 18:16 ` jason at gcc dot gnu.org
  2013-02-13 18:19 ` jason at gcc dot gnu.org
                   ` (2 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: jason at gcc dot gnu.org @ 2013-02-13 18:16 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55710

--- Comment #9 from Jason Merrill <jason at gcc dot gnu.org> 2013-02-13 18:15:42 UTC ---
*** Bug 55720 has been marked as a duplicate of this bug. ***


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

* [Bug c++/55710] [C++11] Linkage errors with lambdas
  2012-12-15 17:11 [Bug c++/55710] New: [C++11] Linkage errors with lambdas daniel.kruegler at googlemail dot com
                   ` (8 preceding siblings ...)
  2013-02-13 18:16 ` jason at gcc dot gnu.org
@ 2013-02-13 18:19 ` jason at gcc dot gnu.org
  2013-02-15 18:32 ` jason at gcc dot gnu.org
  2013-02-15 18:38 ` paolo.carlini at oracle dot com
  11 siblings, 0 replies; 13+ messages in thread
From: jason at gcc dot gnu.org @ 2013-02-13 18:19 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55710

--- Comment #10 from Jason Merrill <jason at gcc dot gnu.org> 2013-02-13 18:18:10 UTC ---
Author: jason
Date: Wed Feb 13 18:17:39 2013
New Revision: 196025

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=196025
Log:
    PR c++/55710
    * semantics.c (maybe_add_lambda_conv_op): Mark static thunk
    TREE_USED.

Added:
    trunk/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-conv7.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/semantics.c


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

* [Bug c++/55710] [C++11] Linkage errors with lambdas
  2012-12-15 17:11 [Bug c++/55710] New: [C++11] Linkage errors with lambdas daniel.kruegler at googlemail dot com
                   ` (9 preceding siblings ...)
  2013-02-13 18:19 ` jason at gcc dot gnu.org
@ 2013-02-15 18:32 ` jason at gcc dot gnu.org
  2013-02-15 18:38 ` paolo.carlini at oracle dot com
  11 siblings, 0 replies; 13+ messages in thread
From: jason at gcc dot gnu.org @ 2013-02-15 18:32 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55710

--- Comment #11 from Jason Merrill <jason at gcc dot gnu.org> 2013-02-15 18:32:05 UTC ---
Author: jason
Date: Fri Feb 15 18:31:52 2013
New Revision: 196086

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=196086
Log:
    PR c++/55710
    * semantics.c (maybe_add_lambda_conv_op): Mark static thunk
    TREE_USED.

Added:
    branches/gcc-4_7-branch/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-conv7.C
Modified:
    branches/gcc-4_7-branch/gcc/cp/ChangeLog
    branches/gcc-4_7-branch/gcc/cp/semantics.c


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

* [Bug c++/55710] [C++11] Linkage errors with lambdas
  2012-12-15 17:11 [Bug c++/55710] New: [C++11] Linkage errors with lambdas daniel.kruegler at googlemail dot com
                   ` (10 preceding siblings ...)
  2013-02-15 18:32 ` jason at gcc dot gnu.org
@ 2013-02-15 18:38 ` paolo.carlini at oracle dot com
  11 siblings, 0 replies; 13+ messages in thread
From: paolo.carlini at oracle dot com @ 2013-02-15 18:38 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55710

Paolo Carlini <paolo.carlini at oracle dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED
   Target Milestone|---                         |4.7.3

--- Comment #12 from Paolo Carlini <paolo.carlini at oracle dot com> 2013-02-15 18:38:00 UTC ---
Thanks Jason! Fixed mainline and 4.7.3.


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

end of thread, other threads:[~2013-02-15 18:38 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-12-15 17:11 [Bug c++/55710] New: [C++11] Linkage errors with lambdas daniel.kruegler at googlemail dot com
2012-12-15 18:29 ` [Bug c++/55710] " pinskia at gcc dot gnu.org
2012-12-15 18:52 ` paolo.carlini at oracle dot com
2012-12-15 18:58 ` daniel.kruegler at googlemail dot com
2012-12-15 19:03 ` paolo.carlini at oracle dot com
2012-12-15 19:07 ` paolo.carlini at oracle dot com
2012-12-15 19:56 ` daniel.kruegler at googlemail dot com
2012-12-17 13:55 ` daniel.kruegler at googlemail dot com
2012-12-19 18:03 ` paolo.carlini at oracle dot com
2013-02-13 18:16 ` jason at gcc dot gnu.org
2013-02-13 18:19 ` jason at gcc dot gnu.org
2013-02-15 18:32 ` jason at gcc dot gnu.org
2013-02-15 18:38 ` 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).