[Bug c++/40007] New: specialization causes access problem in primary template
jwakely dot gcc at gmail dot com
gcc-bugzilla@gcc.gnu.org
Sat May 2 19:52:00 GMT 2009
template<typename T>
struct x
{
protected:
typedef int type;
};
template<typename T>
struct y : public x<T>
{
typedef x<T> base_type;
typedef typename base_type::type type;
};
template<>
struct y<void> : public x<void>
{
typedef x<void> base_type;
typedef base_type::type type;
};
template class y<int>;
int main()
{
return 0;
}
$ g++4x spec.cc
spec.cc: In instantiation of Ây<int>Â:
spec.cc:22: instantiated from here
spec.cc:5: error: Âtypedef int x<void>::type is protected
spec.cc:10: error: within this context
$ g++4x -v
Using built-in specs.
Target: x86_64-unknown-linux-gnu
Configured with: ../gcc-4.x/configure --prefix=/home/redi/gcc/4.x
--with-system-zlib --enable-__cxa_atexit --with-arch=k8
--enable-libstdcxx-debug --disable-libstdcxx-pch --enable-languages=c,c++
--enable-libstdcxx-time=yes --disable-bootstrap --enable-checking=release
Thread model: posix
gcc version 4.5.0 20090502 (experimental) (GCC)
If the base class is not a template there is no error, if the y<void>
specialisation is not defined there is no error. As I'm not using the y<void>
specialisation, its contents should make no difference to the instantiation of
y<int>.
Looks like a regression since 4.3 as it works with gcc version 4.3.2 20081105
(Red Hat 4.3.2-7) (GCC) and Comeau's online compiler.
--
Summary: specialization causes access problem in primary template
Product: gcc
Version: 4.5.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: jwakely dot gcc at gmail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40007
More information about the Gcc-bugs
mailing list