[Bug c++/40055] New: Failing instantiation of template with enums
alexandre dot hamez at gmail dot com
gcc-bugzilla@gcc.gnu.org
Thu May 7 09:43:00 GMT 2009
The following code failed with the message (no options are given to the
compiler):
instance.cc: In function 'int main()':
instance.cc:30: error: no matching function for call to 'c_struct<a_tags,
a_struct>::c_struct(a0_type&)'
instance.cc:14: note: candidates are: c_struct<a_tags,
a_struct>::c_struct(const c_struct<a_tags, a_struct>&)
---------------------------------------
enum a_tags { A0, A1 };
enum b_tags { B0, B1 };
template < a_tags Tag >
struct a_struct
{};
template < b_tags Tag >
struct b_struct
{};
template < typename tags, template < tags > class Element >
struct c_struct
{
template < tags Tag >
c_struct(Element< Tag >)
{}
};
typedef c_struct< a_tags, a_struct > a_type;
typedef c_struct< b_tags, b_struct > b_type;
typedef a_struct< A0 > a0_type;
typedef b_struct< B0 > b0_type;
int main()
{
a0_type a0;
b0_type b0;
b_type b_instance(b0);
a_type a_instance(a0);
}
------------------------------
But if one of the line:
b_type b_instance(b0);
a_type a_instance(a0);
is commented out, then the compilation succeeds.
---------------------------
My g++ version, although I've been able to reproduce this bug with older
versions of gcc:
% /usr/local/env/gcc-4.4.0/bin/g++ -v
Using built-in specs.
Target: i386-apple-darwin9.6.0
Configured with: ../gcc-4.4.0/configure --prefix=/usr/local/env/gcc-4.4.0
--disable-nls --enable-languages=c,c++
Thread model: posix
gcc version 4.4.0 (GCC)
--
Summary: Failing instantiation of template with enums
Product: gcc
Version: 4.4.0
Status: UNCONFIRMED
Severity: critical
Priority: P3
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: alexandre dot hamez at gmail dot com
GCC build triplet: i386-apple-darwin9.6.0
GCC host triplet: i386-apple-darwin9.6.0
GCC target triplet: i386-apple-darwin9.6.0
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40055
More information about the Gcc-bugs
mailing list