public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/55680] New: [C++11] Member specialization with lambda is rejected
@ 2012-12-13 23:03 qufanat at gmail dot com
  2012-12-15 16:44 ` [Bug c++/55680] " daniel.kruegler at googlemail dot com
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: qufanat at gmail dot com @ 2012-12-13 23:03 UTC (permalink / raw)
  To: gcc-bugs


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

             Bug #: 55680
           Summary: [C++11] Member specialization with lambda is rejected
    Classification: Unclassified
           Product: gcc
           Version: 4.7.2
            Status: UNCONFIRMED
          Severity: minor
          Priority: P3
         Component: c++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: qufanat@gmail.com


==== CONTENTS OF speclambda.cpp ====
template <class T> struct X {
    static void (* code ) ();
};
template <> void (* X<int>::code ) () = [](){};
int main () { return 0; }
====================================

==== OUTPUT OF g++-4.7 -std=c++11 ====
speclambda.cpp:4:42: error: explicit specialization of non-template ‘<lambda>’
======================================

It succeeds if I specialize the whole struct instead of just the one member.
The same error occurs if the type of 'code' is std::function<void ()>.
The same error occurs during any kind of static member specialization whose
initializer contains a lambda (such as an initializer that calls a constructor
with a lambda as an argument).

I'm not 100% certain this is valid code, but even if it is invalid, the error
message is quite misleading.

==== OUTPUT OF g++-4.7 -v ====
Using built-in specs.
COLLECT_GCC=g++-4.7
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/4.7/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu/Linaro
4.7.2-11precise2' --with-bugurl=file:///usr/share/doc/gcc-4.7/README.Bugs
--enable-languages=c,c++,go,fortran,objc,obj-c++ --prefix=/usr
--program-suffix=-4.7 --enable-shared --enable-linker-build-id
--with-system-zlib --libexecdir=/usr/lib --without-included-gettext
--enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.7
--libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu
--enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-gnu-unique-object
--enable-plugin --enable-objc-gc --disable-werror --with-arch-32=i686
--with-abi=m64 --with-multilib-list=m32,m64 --with-tune=generic
--enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu
--target=x86_64-linux-gnu
Thread model: posix
gcc version 4.7.2 (Ubuntu/Linaro 4.7.2-11precise2) 
==============================


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

* [Bug c++/55680] [C++11] Member specialization with lambda is rejected
  2012-12-13 23:03 [Bug c++/55680] New: [C++11] Member specialization with lambda is rejected qufanat at gmail dot com
@ 2012-12-15 16:44 ` daniel.kruegler at googlemail dot com
  2013-02-14  4:30 ` jason at gcc dot gnu.org
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: daniel.kruegler at googlemail dot com @ 2012-12-15 16:44 UTC (permalink / raw)
  To: gcc-bugs


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

--- Comment #1 from Daniel Krügler <daniel.kruegler at googlemail dot com> 2012-12-15 16:44:08 UTC ---
The same problem exists for gcc 4.8.0 20121209 (experimental). The code looks
valid to me. I tried to deduce the root of the compiler problem here. For
example trying to rewrite it as

typedef void (*code_t) ();

template <>
code_t X<double>::code = [](){};

but the error still exists.


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

* [Bug c++/55680] [C++11] Member specialization with lambda is rejected
  2012-12-13 23:03 [Bug c++/55680] New: [C++11] Member specialization with lambda is rejected qufanat at gmail dot com
  2012-12-15 16:44 ` [Bug c++/55680] " daniel.kruegler at googlemail dot com
@ 2013-02-14  4:30 ` jason at gcc dot gnu.org
  2013-02-14 23:37 ` paolo.carlini at oracle dot com
  2022-11-30 21:04 ` pinskia at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: jason at gcc dot gnu.org @ 2013-02-14  4:30 UTC (permalink / raw)
  To: gcc-bugs


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

--- Comment #2 from Jason Merrill <jason at gcc dot gnu.org> 2013-02-14 04:30:36 UTC ---
Author: jason
Date: Thu Feb 14 04:30:26 2013
New Revision: 196042

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=196042
Log:
    PR c++/55680
    * pt.c (maybe_process_partial_specialization): A lambda
    isn't what's being specialized.

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


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

* [Bug c++/55680] [C++11] Member specialization with lambda is rejected
  2012-12-13 23:03 [Bug c++/55680] New: [C++11] Member specialization with lambda is rejected qufanat at gmail dot com
  2012-12-15 16:44 ` [Bug c++/55680] " daniel.kruegler at googlemail dot com
  2013-02-14  4:30 ` jason at gcc dot gnu.org
@ 2013-02-14 23:37 ` paolo.carlini at oracle dot com
  2022-11-30 21:04 ` pinskia at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: paolo.carlini at oracle dot com @ 2013-02-14 23:37 UTC (permalink / raw)
  To: gcc-bugs


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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |FIXED

--- Comment #3 from Paolo Carlini <paolo.carlini at oracle dot com> 2013-02-14 23:37:43 UTC ---
Fixed for 4.8.0.


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

* [Bug c++/55680] [C++11] Member specialization with lambda is rejected
  2012-12-13 23:03 [Bug c++/55680] New: [C++11] Member specialization with lambda is rejected qufanat at gmail dot com
                   ` (2 preceding siblings ...)
  2013-02-14 23:37 ` paolo.carlini at oracle dot com
@ 2022-11-30 21:04 ` pinskia at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-11-30 21:04 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=55680

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |4.8.0

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

end of thread, other threads:[~2022-11-30 21:04 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-12-13 23:03 [Bug c++/55680] New: [C++11] Member specialization with lambda is rejected qufanat at gmail dot com
2012-12-15 16:44 ` [Bug c++/55680] " daniel.kruegler at googlemail dot com
2013-02-14  4:30 ` jason at gcc dot gnu.org
2013-02-14 23:37 ` paolo.carlini at oracle dot com
2022-11-30 21:04 ` pinskia at gcc dot gnu.org

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