public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/52183] New: Redeclaration of __this in lambda inside template member function when calling static class function
@ 2012-02-09  9:47 stefan.bolus at gmx dot de
  2012-02-09 11:26 ` [Bug c++/52183] " paolo.carlini at oracle dot com
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: stefan.bolus at gmx dot de @ 2012-02-09  9:47 UTC (permalink / raw)
  To: gcc-bugs

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

             Bug #: 52183
           Summary: Redeclaration of __this in lambda inside template
                    member function when calling static class function
    Classification: Unclassified
           Product: gcc
           Version: 4.7.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: stefan.bolus@gmx.de


When compiling

#include <functional>

struct A
{
  template<class T>
  void f (T x) {
    std::function<void ()> aux;
    aux = [&] () -> void{
      s();
      aux ();
    };
  }

  static void s () { }
};

template void A::f<int> (int);

code is rejected by the compiler by the error message below. Expected behavior
is compilation without an error.

stefan@bluebox:/tmp$ g++-svn -std=c++0x -v --save-temps foo.cpp
Using built-in specs.
COLLECT_GCC=g++-svn
COLLECT_LTO_WRAPPER=/home/stefan/libexec/gcc/x86_64-unknown-linux-gnu/4.7.0/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: ../trunk/configure --enable-languages=c,c++
--prefix=/home/stefan --program-suffix=-svn --disable-multilib
Thread model: posix
gcc version 4.7.0 20120126 (experimental) (GCC) 
COLLECT_GCC_OPTIONS='-std=c++11' '-v' '-save-temps' '-shared-libgcc'
'-mtune=generic' '-march=x86-64'
 /home/stefan/libexec/gcc/x86_64-unknown-linux-gnu/4.7.0/cc1plus -E -quiet -v
-D_GNU_SOURCE foo.cpp -mtune=generic -march=x86-64 -std=c++11 -fpch-preprocess
-o foo.ii
ignoring nonexistent directory
"/home/stefan/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../x86_64-unknown-linux-gnu/include"
#include "..." search starts here:
#include <...> search starts here:

/home/stefan/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0

/home/stefan/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0/x86_64-unknown-linux-gnu

/home/stefan/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0/backward
 /home/stefan/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/include
 /usr/local/include
 /home/stefan/include
 /home/stefan/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/include-fixed
 /usr/include
End of search list.
COLLECT_GCC_OPTIONS='-std=c++11' '-v' '-save-temps' '-shared-libgcc'
'-mtune=generic' '-march=x86-64'
 /home/stefan/libexec/gcc/x86_64-unknown-linux-gnu/4.7.0/cc1plus -fpreprocessed
foo.ii -quiet -dumpbase foo.cpp -mtune=generic -march=x86-64 -auxbase foo
-std=c++11 -version -o foo.s
GNU C++ (GCC) version 4.7.0 20120126 (experimental) (x86_64-unknown-linux-gnu)
    compiled by GNU C version 4.7.0 20120126 (experimental), GMP version 5.0.1,
MPFR version 3.0.1-p3, MPC version 0.9
GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096
GNU C++ (GCC) version 4.7.0 20120126 (experimental) (x86_64-unknown-linux-gnu)
    compiled by GNU C version 4.7.0 20120126 (experimental), GMP version 5.0.1,
MPFR version 3.0.1-p3, MPC version 0.9
GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096
Compiler executable checksum: 587bcf77b9db77a91e3cc4b379a04aff
foo.cpp: In instantiation of ‘A::f(T) [with T = int]::<lambda()>’:
foo.cpp:10:7:   required from ‘struct A::f(T) [with T = int]::<lambda()>’
foo.cpp:8:5:   required from ‘void A::f(T) [with T = int]’
foo.cpp:17:29:   required from here
foo.cpp:9:9: error: redeclaration of ‘A* const A::f(T) [with T =
int]::<lambda()>::__this’
foo.cpp:9:9: note: previous declaration ‘A* const A::f(T) [with T =
int]::<lambda()>::__this’
foo.cpp:9:9: error: redeclaration of ‘A* const this’
foo.cpp:9:9: error: ‘A* const this’ previously declared here
In file included from foo.cpp:1:0:
/home/stefan/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0/functional:2172:2:
error: ‘typename std::enable_if<(! std::is_integral<_Functor>::value),
std::function<_Res(_ArgTypes ...)>&>::type std::function<_Res(_ArgTypes
...)>::operator=(_Functor&&) [with _Functor = A::f(T) [with T =
int]::<lambda()>; _Res = void; _ArgTypes = {}; typename std::enable_if<(!
std::is_integral<_Functor>::value), std::function<_Res(_ArgTypes ...)>&>::type
= std::function<void()>&]’, declared using local type ‘A::f(T) [with T =
int]::<lambda()>’, is used but never defined [-fpermissive]


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

* [Bug c++/52183] Redeclaration of __this in lambda inside template member function when calling static class function
  2012-02-09  9:47 [Bug c++/52183] New: Redeclaration of __this in lambda inside template member function when calling static class function stefan.bolus at gmx dot de
@ 2012-02-09 11:26 ` paolo.carlini at oracle dot com
  2013-03-05 17:46 ` [Bug c++/52183] [C++0x] " jason at gcc dot gnu.org
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: paolo.carlini at oracle dot com @ 2012-02-09 11:26 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2012-02-09
                 CC|                            |paolo.carlini at oracle dot
                   |                            |com
     Ever Confirmed|0                           |1

--- Comment #1 from Paolo Carlini <paolo.carlini at oracle dot com> 2012-02-09 11:25:54 UTC ---
Confirmed. I think this is closely related to PR51494, and indeed my draft
patch for the latter appears to fix this one too, you may want to give it a
try:

  http://gcc.gnu.org/ml/gcc-patches/2011-12/msg01593.html

(by no means I consider my draft close to the final form, eg, likely we want to
leave maybe_dummy_object alone, but I believe it correctly pin points were the
problem is)


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

* [Bug c++/52183] [C++0x] Redeclaration of __this in lambda inside template member function when calling static class function
  2012-02-09  9:47 [Bug c++/52183] New: Redeclaration of __this in lambda inside template member function when calling static class function stefan.bolus at gmx dot de
  2012-02-09 11:26 ` [Bug c++/52183] " paolo.carlini at oracle dot com
@ 2013-03-05 17:46 ` jason at gcc dot gnu.org
  2013-03-08 16:11 ` jason at gcc dot gnu.org
  2013-03-08 16:12 ` jason at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: jason at gcc dot gnu.org @ 2013-03-05 17:46 UTC (permalink / raw)
  To: gcc-bugs


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

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] 5+ messages in thread

* [Bug c++/52183] [C++0x] Redeclaration of __this in lambda inside template member function when calling static class function
  2012-02-09  9:47 [Bug c++/52183] New: Redeclaration of __this in lambda inside template member function when calling static class function stefan.bolus at gmx dot de
  2012-02-09 11:26 ` [Bug c++/52183] " paolo.carlini at oracle dot com
  2013-03-05 17:46 ` [Bug c++/52183] [C++0x] " jason at gcc dot gnu.org
@ 2013-03-08 16:11 ` jason at gcc dot gnu.org
  2013-03-08 16:12 ` jason at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: jason at gcc dot gnu.org @ 2013-03-08 16:11 UTC (permalink / raw)
  To: gcc-bugs


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

--- Comment #2 from Jason Merrill <jason at gcc dot gnu.org> 2013-03-08 16:10:24 UTC ---
Author: jason
Date: Fri Mar  8 16:10:19 2013
New Revision: 196552

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=196552
Log:
    PR c++/52183
    Correct PR tag.

Modified:
    trunk/gcc/cp/ChangeLog


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

* [Bug c++/52183] [C++0x] Redeclaration of __this in lambda inside template member function when calling static class function
  2012-02-09  9:47 [Bug c++/52183] New: Redeclaration of __this in lambda inside template member function when calling static class function stefan.bolus at gmx dot de
                   ` (2 preceding siblings ...)
  2013-03-08 16:11 ` jason at gcc dot gnu.org
@ 2013-03-08 16:12 ` jason at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: jason at gcc dot gnu.org @ 2013-03-08 16:12 UTC (permalink / raw)
  To: gcc-bugs


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

Jason Merrill <jason at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED
   Target Milestone|---                         |4.8.0

--- Comment #3 from Jason Merrill <jason at gcc dot gnu.org> 2013-03-08 16:11:36 UTC ---
Fixed for 4.8.


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

end of thread, other threads:[~2013-03-08 16:12 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-02-09  9:47 [Bug c++/52183] New: Redeclaration of __this in lambda inside template member function when calling static class function stefan.bolus at gmx dot de
2012-02-09 11:26 ` [Bug c++/52183] " paolo.carlini at oracle dot com
2013-03-05 17:46 ` [Bug c++/52183] [C++0x] " jason at gcc dot gnu.org
2013-03-08 16:11 ` jason at gcc dot gnu.org
2013-03-08 16:12 ` jason 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).