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



--- Comment #3 from Jonathan Wakely <redi at gcc dot gnu.org> 2012-12-19 
15:54:22 UTC ---

(Your testcase would be a lot easier to read without all those comments inside

the conditional expression, I think it's safe to assume everyone here knows

which is the false branch of a conditional expression!)



A conditional expression is not a "static if" so  templates in both branches of

the conditional expression are instantiated, and instantiating DivByX<0> fails.



You could work around this by preventing instantiation of the problem case, the

simplest way is to specialize the template:



template <>

struct DivByX<0>

{

    enum

    {

        value1 = X,

        value2 = 0;

    };

};



Now it doesn't matter if the DivByX<0> case is instantiated because it doesn't

divide by zero.

Reply via email to