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

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).