Clang error on decltype test case

Hi all,

This is with respect to the following test case

bool b;
template auto f (T t) → decltype(b?t:throw 42) { return 0; }
template auto f2 (T t) → decltype(b?t:throw) { return 0; }

int main()
{
f(0);
f2(0);
}

g++ doesn’t throw an error whereas clang complains on compiling. The error is

"non-const lvalue reference to type ‘int’ cannot bind to a temporary of type ‘int’ ".

As far as my analysis goes, decltype(throw 42) returns void and decltype(t) returns T
Now depending upon the Boolean b, return type of f and f2 are decided and as this is

non-constant without the knowledge of b, when clang tries to bind this with the value ‘0’,

it throws this error.
Is my above analysis correct or Am I missing something ? Is clang’s behavior correct with respect to this test case?
If not, please help me in understanding it better

Thanks,
Chakshu

201410091712808_BEI0XT4N.gif