[Bug c++/40007] [4.5 regression] specialization causes access problem in primary template
jwakely dot gcc at gmail dot com
gcc-bugzilla@gcc.gnu.org
Fri May 8 20:52:00 GMT 2009
------- Comment #3 from jwakely dot gcc at gmail dot com 2009-05-08 20:52 -------
Debugging cc1plus for this slightly reduced program:
template<typename T>
struct x
{
protected:
typedef int type;
};
template<typename T>
struct y : public x<T>
{
typename x<T>::type z;
};
template<>
struct y<void> : public x<void>
{
typedef x<void>::type z;
};
template class y<int>;
shows the explicit instantiation of y<int> calls
perform_typedefs_access_check() which calls
enforce_access() with decl = x<void>::type.
That's wrong, it should be x<int>::type - somehow the wrong typedef is
added to the list of types to check for the y<int> specialisation.
(gdb) bt
#0 enforce_access (basetype_path=0x2aaaab643180, decl=0x2aaaab641cc0,
diag_decl=0x2aaaab641cc0) at ../../src/gcc/gcc/cp/call.c:4447
#1 0x00000000004acabc in perform_typedefs_access_check (
tmpl=<value optimized out>, targs=0x2aaaab6429c0)
at ../../src/gcc/gcc/cp/pt.c:6960
#2 0x00000000004b827b in instantiate_class_template (type=0x2aaaab644240)
at ../../src/gcc/gcc/cp/pt.c:7443
#3 0x00000000004edf00 in complete_type (type=0x2aaaab644240)
at ../../src/gcc/gcc/cp/typeck.c:130
#4 0x00000000004b062c in do_type_instantiation (t=0x2aaaab644240,
storage=0x0, complain=1) at ../../src/gcc/gcc/cp/pt.c:15011
#5 0x00000000004e0f11 in cp_parser_explicit_instantiation (
parser=0x2aaaab4b59b0) at ../../src/gcc/gcc/cp/parser.c:10812
#6 0x00000000004e6905 in cp_parser_declaration (parser=0x2aaaab4b59b0)
at ../../src/gcc/gcc/cp/parser.c:8013
#7 0x00000000004e6caa in cp_parser_declaration_seq_opt (parser=0x2aaaab4b59b0)
at ../../src/gcc/gcc/cp/parser.c:7927
#8 0x00000000004e7527 in c_parse_file () at ../../src/gcc/gcc/cp/parser.c:3029
#9 0x00000000005557fa in c_common_parse_file (
set_yydebug=<value optimized out>) at ../../src/gcc/gcc/c-opts.c:1272
#10 0x00000000007519e2 in toplev_main (argc=13, argv=0x7fffffffe8a8)
at ../../src/gcc/gcc/toplev.c:979
#11 0x00002aaaaace24ca in __libc_start_main () from /lib/libc.so.6
#12 0x000000000048216a in _start () at ../sysdeps/x86_64/elf/start.S:113
(gdb) n
4448 gcc_assert (TREE_CODE (basetype_path) == TREE_BINFO);
(gdb)
4450 if (!accessible_p (basetype_path, decl, true))
(gdb)
4452 if (TREE_PRIVATE (decl))
(gdb)
4454 else if (TREE_PROTECTED (decl))
(gdb)
4455 error ("%q+#D is protected", diag_decl);
(gdb)
pr40007.cc: In instantiation of Ây<int>Â:
pr40007.cc:20: instantiated from here
pr40007.cc:5: error: Âtypedef int x<void>::type is protected
4458 error ("within this context");
(gdb)
pr40007.cc:10: error: within this context
4463 }
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40007
More information about the Gcc-bugs
mailing list