[PR44629] internal compiler error in unify

Bug #541425 reported by stestagg
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
gcc
Fix Released
Medium
gcc-4.3 (Ubuntu)
Confirmed
Low
Unassigned

Bug Description

Binary package hint: gcc-4.3

Trying to compile the attached, preprocessed, source gives the error:

../aclib/aclib.cpp: In function ‘void ac_print_dot(acSearcher*)’:
../aclib/aclib.cpp:35: internal compiler error: in unify, at cp/pt.c:13439
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-4.3/README.Bugs> for instructions.

GCC version:

Using built-in specs.
Target: i486-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 4.3.3-5ubuntu4' --with-bugurl=file:///usr/share/doc/gcc-4.3/README.Bugs --enable-languages=c,c++,fortran,objc,obj-c++ --prefix=/usr --enable-shared --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --enable-nls --with-gxx-include-dir=/usr/include/c++/4.3 --program-suffix=-4.3 --enable-clocale=gnu --enable-libstdcxx-debug --enable-objc-gc --enable-mpfr --enable-targets=all --with-tune=generic --enable-checking=release --build=i486-linux-gnu --host=i486-linux-gnu --target=i486-linux-gnu
Thread model: posix
gcc version 4.3.3 (Ubuntu 4.3.3-5ubuntu4)

on Ubuntu 9.04

Revision history for this message
stestagg (stestagg) wrote :
Revision history for this message
stestagg (stestagg) wrote :

Also happens on gcc-snapshot

Using built-in specs.
Target: i486-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 20090327-0ubuntu1' --with-bugurl=file:///usr/share/doc/gcc-snapshot/README.Bugs --enable-languages=c,c++,java,fortran,objc,obj-c++,ada --prefix=/usr/lib/gcc-snapshot --enable-shared --enable-multiarch --with-system-zlib --disable-nls --enable-clocale=gnu --enable-libstdcxx-debug --enable-java-awt=gtk --enable-gtk-cairo --disable-plugin --with-java-home=/usr/lib/gcc-snapshot/java-1.5.0-gcj-4.4-1.5.0.0/jre --enable-java-home --with-jvm-root-dir=/usr/lib/gcc-snapshot/jvm --with-jvm-jar-dir=/usr/lib/gcc-snapshot/jvm-exports --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --enable-objc-gc --enable-mpfr --enable-targets=all --disable-werror --with-tune=generic --build=i486-linux-gnu --host=i486-linux-gnu --target=i486-linux-gnu
Thread model: posix
gcc version 4.4.0 20090327 (experimental) [trunk revision 145121] (Ubuntu 20090327-0ubuntu1)

sstagg@sphinx:~/src/acSearch/aclibtest$ g++ aclib.i
../aclib/aclib.cpp: In function 'void ac_print_dot(acSearcher*)':
../aclib/aclib.cpp:35: internal compiler error: in unify, at cp/pt.c:13924
Please submit a full bug report,

Revision history for this message
In , Matthias Klose (doko) wrote :

seen with 4.3, 4.4, 4.5, 4.6

$ gcc-4.5 -c aclib.ii
../aclib/aclib.cpp: In function 'void ac_print_dot(acSearcher*)':
../aclib/aclib.cpp:35:61: internal compiler error: in unify, at cp/pt.c:15155
Please submit a full bug report,
with preprocessed source if appropriate.

Revision history for this message
In , Matthias Klose (doko) wrote :

Created attachment 20976
preprocessed source

Revision history for this message
Matthias Klose (doko) wrote :

seen with 4.4 and 4.5 too

Changed in gcc-4.3 (Ubuntu):
importance: Undecided → Low
status: New → Confirmed
summary: - internal compiler error in unify
+ [PR44629] internal compiler error in unify
Changed in gcc:
status: Unknown → New
Revision history for this message
In , Rguenth (rguenth) wrote :

Confirmed.

../aclib/aclib.cpp(35): error: no instance of function template "ACSearch::Grapher::simple_output" matches the argument list
            argument types are: (acSearcher)
    std::basic_string<char> output = Grapher::simple_output(*s);
                                     ^
Reduced testcase for the ICE:

template<typename _CharT> struct char_traits;
namespace __gnu_cxx __attribute__ ((__visibility__ ("default"))) {
    template<typename _Tp> class new_allocator { };
}
namespace std __attribute__ ((__visibility__ ("default"))) {
    template<typename _Tp>
    class allocator: public __gnu_cxx::new_allocator<_Tp> { };
    template<typename _CharT, typename _Traits = char_traits<_CharT>, typename _Alloc = allocator<_CharT> > class basic_string;
    template<typename _CharT, typename _Traits, typename _Alloc>
    class basic_string {
    };
}
template<typename T> int eq_cmp(T a, T b){ }
template<typename T> int unsafe_case_cmp(T a, T b){ }
template<typename T, int (*cmp_fn)(T, T) = eq_cmp> class Searcher{ };
class Grapher{
    template <typename T>
    static std::basic_string<T> simple_output(Searcher<T> &sch){ }
};
typedef Searcher<char, unsafe_case_cmp> acSearcher;
void ac_print_dot(acSearcher *s){
    std::basic_string<char> output = Grapher::simple_output(*s);
}

Revision history for this message
In , Jakub-gcc (jakub-gcc) wrote :

3.4 gives here:
pr44629.C:23: sorry, unimplemented: use of `overload' in template type unification
pr44629.C:23: error: no matching function for call to `Grapher::simple_output(Searcher<char, unsafe_case_cmp [with T = char]>&)'
 int unsafe_case_cmp(T, T) [with T = char]

So it is a regression.

Changed in gcc:
status: New → Confirmed
Revision history for this message
In , Jason-gcc (jason-gcc) wrote :

Same ICE on valid testcase:

template<typename T> int cmp1(T a, T b);
template<typename T> int cmp2(T a, T b);
template<typename T, int (*cmp)(T, T) = cmp1> struct A { };
template <typename T> void f (A<T> &);
void g()
{
  A<char> a;
  f(a);
}

though 3.4 didn't accept it, it gave the same sorry, so it isn't a big regression.

Revision history for this message
In , Jason-gcc (jason-gcc) wrote :

Created attachment 23550
WIP patch to accept my testcase

Here's a patch that makes my testcase work. I don't want to put it in 4.6 because it produces mangling different from the EDG compiler, and want to clarify how it should mangle first.

Revision history for this message
In , Jason-gcc (jason-gcc) wrote :

Created attachment 23551
WIP patch to make the testcase sorry as before

And here's a patch that just restores the previous sorry behavior. Do you think it's worth applying this to 4.6?

Changed in gcc:
importance: Unknown → Medium
Revision history for this message
In , Jason-gcc (jason-gcc) wrote :

A middle ground would be to fix the bug in unify without adding mangling support, so we get the sorry there. I guess I'll do that.

Revision history for this message
In , Jason-gcc (jason-gcc) wrote :

Author: jason
Date: Wed Mar 9 17:57:46 2011
New Revision: 170824

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=170824
Log:
 PR c++/44629
 * pt.c (unify): An unresolved overload is a nondeduced context.

Added:
    trunk/gcc/testsuite/g++.dg/template/nontype22.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/pt.c
    trunk/gcc/testsuite/ChangeLog

Revision history for this message
In , Jason-gcc (jason-gcc) wrote :

Author: jason
Date: Wed Mar 9 17:57:48 2011
New Revision: 170825

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=170825
Log:
 PR c++/44629
 * pt.c (unify): An unresolved overload is a nondeduced context.

Added:
    branches/gcc-4_4-branch/gcc/testsuite/g++.dg/template/nontype22.C
Modified:
    branches/gcc-4_4-branch/gcc/cp/ChangeLog
    branches/gcc-4_4-branch/gcc/cp/pt.c
    branches/gcc-4_4-branch/gcc/testsuite/ChangeLog

Revision history for this message
In , Jason-gcc (jason-gcc) wrote :

Author: jason
Date: Wed Mar 9 17:57:51 2011
New Revision: 170826

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=170826
Log:
 PR c++/44629
 * pt.c (unify): An unresolved overload is a nondeduced context.

Added:
    branches/gcc-4_5-branch/gcc/testsuite/g++.dg/template/nontype22.C
Modified:
    branches/gcc-4_5-branch/gcc/cp/ChangeLog
    branches/gcc-4_5-branch/gcc/cp/pt.c
    branches/gcc-4_5-branch/gcc/testsuite/ChangeLog

Revision history for this message
In , Jason-gcc (jason-gcc) wrote :

ICE fixed in 4.4, 4.5, 4.6. Not worth applying to 4.3 at this point I think.

Revision history for this message
In , Bangerth (bangerth) wrote :

(In reply to comment #4)
> template<typename T> int cmp1(T a, T b);
> template<typename T> int cmp2(T a, T b);
> template<typename T, int (*cmp)(T, T) = cmp1> struct A { };

I'm confused why this would be an overload set. cmp1 is a template so I
can't see how this code would even begin to be valid without specifying
the template argument in the default argument...

W.

Revision history for this message
In , Jason-gcc (jason-gcc) wrote :

(In reply to comment #12)
> I'm confused why this would be an overload set. cmp1 is a template so I
> can't see how this code would even begin to be valid without specifying
> the template argument in the default argument...

Once you know A's T, you have a desired type int (*)(T, T) from which to determine which specialization of the template to use.

Revision history for this message
In , Bangerth (bangerth) wrote :

(In reply to comment #13)
> Once you know A's T, you have a desired type int (*)(T, T) from which to
> determine which specialization of the template to use.

Hm, I agree that the type could be deduced. I could nevertheless
have sworn that this should be invalid:
..........................
template <typename T> int cmp1(T a, T b);
int (*cmp)(int, int) = cmp1;
...........................
But it compiles in fact.

I had no idea a template name could be implicitly instantiated in this
context. Thanks for educating me!

Best
 W.

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

Other bug subscribers

Bug attachments

Remote bug watches

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