llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
29.24k stars 12.07k forks source link

dejagnu test fails to compiler with clang g++.old-deja/g++.pt/ttp22.c #11151

Open llvmbot opened 13 years ago

llvmbot commented 13 years ago
Bugzilla Link 10779
Version 2.9
OS Linux
Attachments ttp22.c
Reporter LLVM Bugzilla Contributor

Extended Description

compiles fine with g++ and intel edg based compiler

/home/rkotler/gcc-4.4.6/gcc/testsuite/g++.old-deja/g++.pt/ttp22.C:27:22: error: 'D' is a private member of 'D' int f() { return C<D,int>::f(); } ^ /home/rkotler/gcc-4.4.6/gcc/testsuite/g++.old-deja/g++.pt/ttp22.C:13:55: note: constrained by implicitly private inheritance here template<template class DD,class EE> class C : DD ^~ /home/rkotler/gcc-4.4.6/gcc/testsuite/g++.old-deja/g++.pt/ttp22.C:2:25: note: member is declared here template class D ^ /home/rkotler/gcc-4.4.6/gcc/testsuite/g++.old-deja/g++.pt/ttp22.C:27:22: error: template argument for template template parameter must be a class template int f() { return C<D,int>::f(); } ^ 2 errors generated.

rkotler@ubuntu-rkotler:~/icpc$ icpc /home/rkotler/gcc-4.4.6/gcc/testsuite/g++.old-deja/g++.pt/ttp22.C rkotler@ubuntu-rkotler:~/icpc$ g++ /home/rkotler/gcc-4.4.6/gcc/testsuite/g++.old-deja/g++.pt/ttp22.C

shafik commented 1 year ago

Given:

// { dg-do run  }
template<class T> class D {
    public:
        int f();
};

template<class T> int D<T>::f() {
    return sizeof(T);
}

template<template<class> class DD,class EE> class C : DD<EE> {
    public:
        int f();
};

template<template<class> class DD,class EE> int C<DD,EE>::f() {
    return DD<EE>::f();
}

class E : C<D,int> {
    public:
        int f() { return C<D,int>::f(); }
};

int main() {
    E c;
    c.f();
}

clang/gcc/MSVC agree this is ill-formed although it looks like EDG does not: https://godbolt.org/z/dehsGMW7v