Renegat
unread,Jul 25, 2023, 8:36:58 PM7/25/23You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to
Hello everybody,
do you agree that the following template related problem is a bug in the g++ front-end of GCC?
If someone with a GCC bugzilla account thinks so, maybe he can submit a bug report there (the automatic account creation has been restricted now).
Thanks.
/*
Product: gcc
Comp: c++
Versions: 11.4 / 12.3 / 13.1 (all currently supported)
Summary: False access error for non-type template parameter of a nested class
Keywords: rejects-valid, accepts-invalid
*/
//
// The out-of-class definition of a nested class member template with a
// private non-type template parameter triggers a false compilation error
//
class A
{
enum e{ E };
template <A::e T>
struct class_template;
};
// BUG #1: This definition outside the class body is valid, but g++ aborts
// the compilation with an error: ‘enum A::e’ is private within this context’
template <A::e T>
struct A::class_template
{
};
// Maybe helpful for a bug fix:
// The compilation error is not triggered for a similar class with a member
// function template defined outside the class body
class B
{
enum e{ E };
template <B::e T>
void function_template();
};
// g++ compiles fine for a function template :
template <B::e T>
void B::function_template()
{
}
// BUG #2: g++ compiles this without any error, but ‘B::e’ is private within
// this context
template <B::e T>
void global_function_template()
{
}
// No BUG here: For a similar class template the g++ compiler correctly reports
// a compilation error (‘enum B::e’ is private within this context)
template <B::e T>
class global_class_template
{
};