------- Comment #2 from bangerth at dealii dot org 2008-03-05 02:55 -------
This is called two-stage name lookup: when parsing a template all occurrences of "things" that do not depend on the template parameter are bound to their global definitions. Thus, here... > template <class Reason> > class not_compilable > { > enum { dummy_value = sizeof (static_assert<false>) }; > }; ...even though we're in a template the compiler sees that static_assert<false> is a classname that does not depend on the (currently) unknown template parameter 'Reason' and so is supposed to be replaced for sizeof. This fails, a behavior mandated by the C++ standard. On the other hand, here... > template <class Reason> > class not_compilable > { > static static_assert<false> dummy_fct (); > enum { dummy_value = sizeof (dummy_fct ()) }; > }; ...you ask the compiler to evaluate sizeof (not_compilable<Reason>::dummy_fct()) which depends on the template parameter 'Reason' and so its evaluation is deferred till we know the template type 'Reason', i.e. till instantiation time. If you never instantiate it, there's no error. W. -- bangerth at dealii dot org changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |bangerth at dealii dot org Status|UNCONFIRMED |RESOLVED Resolution| |INVALID http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35394