[Bug c++/58080] internal compiler error, decltype in function declaration (for SFINAE purposes)

nickolay.merkin at gmail dot com gcc-bugzilla@gcc.gnu.org
Sun Aug 4 19:26:00 GMT 2013


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

--- Comment #4 from Nickolay Merkin <nickolay.merkin at gmail dot com> ---
(In reply to Paolo Carlini from comment #3)
> I meant something else: I meant that on a different compiler, your code
> could be hardly rejected, you should not use arithmetic on void * in the
> first place.

I understand that.
My multimethod is intended to take 'good' combinations from 'bad', so that
int+int or int+char* are good,
char*+char* is bad,
and int+void* should be bad, too.

Say,

template<class A, class B>
auto plus_impl(A a, B b) -> decltype(a+b) { return a+b; }
int plus_impl(...) { throw bad_operands(); }

template<class A, class B>
variant_type plus(A a, B b)
{ return variant_type(plus_impl(a,b)); }

To bypass the ICE, I'd like just to add overloads of plus_impl those receive
void* as left or right operand and throw the exception as well.
But this is a bypass.

Tomorrow I'll explore how VC2010 behaves, maybe it is common problem, and the
bypass is strongly required.



More information about the Gcc-bugs mailing list