This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/29518] [4.0/4.1/4.2/4.3 Regression] rejects valid template argument, enums vs templates



------- Comment #12 from news at derived-software dot ltd dot uk  2006-11-12 11:04 -------
>From Aleksey Gurtovoy (co-author Boost.MPL):
[wrt to this bug]
Actually, no, enums in the bug's subject and reduced test case are a
red herring. For example, this still fails for me on 4.1.1:

template< int C > int assertion_failed(int);
template< class > struct N
{
  static int const value = 1;
  static int const t = sizeof( assertion_failed<value>(0) );
};

int main()
{
  N<int> n;
  return n.t;
}


As a matter of fact, my current workaround for this issue involves
_introducing_ an auxiliary enum for the values that are used in
function templates' non-type arguments, e.g.:

template< int C > int assertion_failed(int);
template< class > struct N
{
  static int const value = 1;
  enum { gcc_workaround = value };
  static int const t = sizeof( assertion_failed<gcc_workaround>(0) ); // it
compiles, yay!
};


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29518


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]