// { dg-do assemble } // by Alexandre Oliva // I'm not 100% sure this program is correct, but g++ shouldn't just // crash. // The idea is to give privileged access to bar only to // specializations foo, for all B. template void foo(); template class bar { int i; // { dg-error "" } private template friend void foo(); // { dg-error "" } bogus declaration }; template void foo() { bar baz; baz.i = 1; // { dg-error "" } foo cannot access bar::i bar buz; buz.i = 1; // { dg-error "" } foo cannot access bar::i } int main() { foo(); foo(); }