internal compiler error: in tsubst_copy

Bug #1036320 reported by Joris Van Remoortere
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
gcc
Invalid
Medium
gcc-4.7 (Ubuntu)
Triaged
Medium
Unassigned

Bug Description

lsb_release -rd:
Description: Ubuntu 12.04 LTS
Release: 12.04

gcc -v:
Using built-in specs.
COLLECT_GCC=gcc
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.0-7ubuntu3' --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 --disable-bootstrap --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-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.0 (Ubuntu/Linaro 4.7.0-7ubuntu3)

Command:
g++ -DTEST_OUTPUT_DIR="/tmp/" -g -Wno-type-limits -Werror -DDEBUG -Wno-parentheses -Wold-style-cast -Wall -Wextra -std=c++0x -I/usr/include/ -I/usr/lib/gcc/x86_64-linux-gnu/4.6.1/include-fixed/ -I/usr/lib/gcc/x86_64-linux-gnu/4.6.1/include/ -c -I/home/XXX/projects/src -I/home/XXX/projects/out/debug -o/home/XXX/projects/out/debug/exp/joris/gcc/inline_cons.o -D'SRC_ROOT="/home/XXX/projects/src"' /home/XXX/projects/src/exp/joris/gcc/inline_cons.cc
exp/joris/gcc/inline_cons.cc:
/home/XXX/projects/src/exp/joris/gcc/inline_cons.cc: In constructor ‘TFoo<TVal>::TFoo(const std::function<bool(const TVal&, const TVal&)>&) [with TVal = int]’:
/home/XXX/projects/src/exp/joris/gcc/inline_cons.cc:12:13: internal compiler error: in tsubst_copy, at cp/pt.c:12113

Source:

#include <functional>
template <typename TVal>
class TFoo {
  public:
  TFoo(const std::function<bool (const TVal &, const TVal &)> &func = [](const TVal &lhs, const TVal &rhs){return lhs < rhs;}) {}
};
int main() {
  TFoo<int> foo;
}

Revision history for this message
In , Richard Eames (naddiseo) wrote :

$ g++ -std=c++0x -o test.bin testcase.cpp
test.cpp: In member function ‘void Foo::dostuff(T, U) [with T = Bar, U = bool(Arg*)]’:
test.cpp:21:17: internal compiler error: in tsubst_copy, at cp/pt.c:11333
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-4.6/README.Bugs> for instructions.

$ g++ -v
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/4.6.1/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu/Linaro 4.6.1-9ubuntu3' --with-bugurl=file:///usr/share/doc/gcc-4.6/README.Bugs --enable-languages=c,c++,fortran,objc,obj-c++,go --prefix=/usr --program-suffix=-4.6 --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.6 --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-plugin --enable-objc-gc --disable-werror --with-arch-32=i686 --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.6.1 (Ubuntu/Linaro 4.6.1-9ubuntu3)

Revision history for this message
In , Richard Eames (naddiseo) wrote :

Created attachment 26304
Testcase

Revision history for this message
In , Richard Eames (naddiseo) wrote :

Tested in 4.7.0, fails too.

$ /usr/lib/gcc-snapshot/bin/g++ -std=c++0x -o test.bin testcase.cpp
testcase.cpp: In member function 'void Foo::dostuff(T, U) [with T = Bar; U = bool(Arg*)]':
testcase.cpp:21:17: internal compiler error: in tsubst_copy, at cp/pt.c:11748

$ /usr/lib/gcc-snapshot/bin/g++ -v
Using built-in specs.
COLLECT_GCC=/usr/lib/gcc-snapshot/bin/g++
COLLECT_LTO_WRAPPER=/usr/lib/gcc-snapshot/libexec/gcc/x86_64-linux-gnu/4.7.0/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu/Linaro 20111010-0ubuntu1' --with-bugurl=file:///usr/share/doc/gcc-snapshot/README.Bugs --enable-languages=c,ada,c++,java,fortran,objc,obj-c++,go --prefix=/usr/lib/gcc-snapshot --enable-shared --enable-linker-build-id --with-system-zlib --disable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-plugin --disable-browser-plugin --enable-java-awt=gtk --enable-gtk-cairo --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-4.7-snap/jre --enable-java-home --with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-4.7-snap --with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-4.7-snap --with-arch-directory=amd64 --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --enable-objc-gc --disable-werror --with-arch-32=i686 --with-tune=generic --enable-checking=yes --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 4.7.0 20111010 (experimental) [trunk revision 179769] (Ubuntu/Linaro 20111010-0ubuntu1)

Revision history for this message
In , Rguenth (rguenth) wrote :

Confirmed. Not sure if the testcase is valid or not.

Revision history for this message
In , Redi (redi) wrote :

It's not valid, you can't pass a function type by value

Revision history for this message
In , Richard Eames (naddiseo) wrote :

I've reduced the testcase further. It appears to be a problem with templates. The reason I was passing a function type in the template was because std::function<bool(Arg*)> wouldn't work for me. If I take out the first parameter so that it's just the function pointer, then std::function works with the lambda as a default argument, but as soon as the function is templated I get the IRC.

Revision history for this message
In , Richard Eames (naddiseo) wrote :

Created attachment 26309
Reduced test case

Revision history for this message
In , Redi (redi) wrote :

Further reduced

struct function
{
  template<typename T>
    function(T) { }
};

class Foo {
public:
  template<typename>
    void dostuff(function callback = []() { }) { }
};

int main() {
  Foo foo;
  foo.dostuff<int>();
}

Revision history for this message
Joris Van Remoortere (y-joris) wrote :
Revision history for this message
Matthias Klose (doko) wrote :

confirmed for 4.6, 4.7 and snapshot

Changed in gcc-4.7 (Ubuntu):
importance: Undecided → Medium
status: New → Triaged
Changed in gcc:
importance: Unknown → Medium
status: Unknown → Confirmed
Revision history for this message
In , Paolo-carlini (paolo-carlini) wrote :

This is fixed in mainline. I'm adding the reduced testcase and closing the issue.

Revision history for this message
In , Paolo-carlini (paolo-carlini) wrote :

It's in fact a Dup.

*** This bug has been marked as a duplicate of bug 55223 ***

Changed in gcc:
status: Confirmed → Invalid
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.