[Bug c++/43790] New: In lambda express, calling member function of non-captured class gives internal compiler error

darlingm at gmail dot com gcc-bugzilla@gcc.gnu.org
Mon Apr 19 04:58:00 GMT 2010


The below at the bottom of this comment gives:

/usr/local/bin/g++ -v -save-temps -std=gnu++0x -o
CMakeFiles/gccError.dir/gccError.cpp.o -c
/home/darlingm/code.gccerror/testing/gccError/gccError.cpp

Using built-in specs.
COLLECT_GCC=/usr/local/bin/g++
COLLECT_LTO_WRAPPER=/usr/local/libexec/gcc/x86_64-unknown-linux-gnu/4.6.0/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: ../gcc/configure --disable-multilib --enable-language=c,c++
--disable-nls
Thread model: posix
gcc version 4.6.0 20100418 (experimental) (GCC) 
COLLECT_GCC_OPTIONS='-v' '-save-temps' '-std=gnu++0x' '-o'
'CMakeFiles/gccError.dir/gccError.cpp.o' '-c' '-shared-libgcc' '-mtune=generic'
'-march=x86-64'
 /usr/local/libexec/gcc/x86_64-unknown-linux-gnu/4.6.0/cc1plus -E -quiet -v
-D_GNU_SOURCE /home/mdarling/code.gccerror/testing/gccError/gccError.cpp
-mtune=generic -march=x86-64 -std=gnu++0x -fpch-preprocess -o gccError.ii
ignoring nonexistent directory
"/usr/local/lib/gcc/x86_64-unknown-linux-gnu/4.6.0/../../../../x86_64-unknown-linux-gnu/include"
#include "..." search starts here:
#include <...> search starts here:

/usr/local/lib/gcc/x86_64-unknown-linux-gnu/4.6.0/../../../../include/c++/4.6.0

/usr/local/lib/gcc/x86_64-unknown-linux-gnu/4.6.0/../../../../include/c++/4.6.0/x86_64-unknown-linux-gnu

/usr/local/lib/gcc/x86_64-unknown-linux-gnu/4.6.0/../../../../include/c++/4.6.0/backward
 /usr/local/include
 /usr/local/lib/gcc/x86_64-unknown-linux-gnu/4.6.0/include
 /usr/local/lib/gcc/x86_64-unknown-linux-gnu/4.6.0/include-fixed
 /usr/include
End of search list.
COLLECT_GCC_OPTIONS='-v' '-save-temps' '-std=gnu++0x' '-o'
'CMakeFiles/gccError.dir/gccError.cpp.o' '-c' '-shared-libgcc' '-mtune=generic'
'-march=x86-64'
 /usr/local/libexec/gcc/x86_64-unknown-linux-gnu/4.6.0/cc1plus -fpreprocessed
gccError.ii -quiet -dumpbase gccError.cpp -mtune=generic -march=x86-64
-auxbase-strip CMakeFiles/gccError.dir/gccError.cpp.o -std=gnu++0x -version -o
gccError.s
GNU C++ (GCC) version 4.6.0 20100418 (experimental) (x86_64-unknown-linux-gnu)
        compiled by GNU C version 4.6.0 20100418 (experimental), GMP version
4.3.1, MPFR version 2.4.2, MPC version 0.8.1
GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096
GNU C++ (GCC) version 4.6.0 20100418 (experimental) (x86_64-unknown-linux-gnu)
        compiled by GNU C version 4.6.0 20100418 (experimental), GMP version
4.3.1, MPFR version 2.4.2, MPC version 0.8.1
GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096
Compiler executable checksum: 7af0c1b1da9d8e649a58d85fd58b2bfb
/home/mdarling/code.gccerror/testing/gccError/gccError.cpp: In lambda function:
/home/mdarling/code.gccerror/testing/gccError/gccError.cpp:25:14: error:
'classInstance' is not captured
/home/mdarling/code.gccerror/testing/gccError/gccError.cpp:26:4: internal
compiler error: tree check: expected class 'type', have 'exceptional'
(error_mark) in cv_unqualified, at cp/tree.c:937
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://gcc.gnu.org/bugs.html> for instructions.



The original internal compiler error was of course in a much larger project,
and had a bunch of other code errors on it being the first compile attempt.  I
got tunnel visioned at the first sight of an internal compiler error and spent
hours re-checking out the svn gcc source and recompiling, in case my svn
version from a week ago had a fixed bug in it.

After removing irrelevant portions of the program to get down to a small test
case, it appears that calling a member function of a non-captured class gives
an internal compiler error.  Properly changing the lambda expression line to
"function<string ()> lambdaExpression = [&classInstance] () {" prevents the
internal compiler error.

I know it's invalid c++0x code that's causing the internal compiler error, but
removing the internal compiler error and only showing the message "error:
'classInstance' is not captured" might save someone else a few hours who gets
tunnel visioned on the one error.  :)


==========
#include <iostream>
#include <string>
#include <functional>
using namespace std;

class theClass {
   public:
      theClass();
      string getA();
   private:
      string a;
};

theClass::theClass() 
: a("theData") {
}

string theClass::getA() {
   return a;
}

int main() {
   theClass classInstance;
   function<string ()> lambdaExpression = [] () {
      return classInstance.getA();
   }; 
   cout << lambdaExpression() << endl;
}


-- 
           Summary: In lambda express, calling member function of non-
                    captured class gives internal compiler error
           Product: gcc
           Version: 4.6.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: darlingm at gmail dot com


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



More information about the Gcc-bugs mailing list