llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
29.42k stars 12.15k forks source link

narrowing conversion in initializer list not treated as SFINAE condition #13982

Closed ec04fc15-fa35-46f2-80e1-5d271f2ef708 closed 10 years ago

ec04fc15-fa35-46f2-80e1-5d271f2ef708 commented 12 years ago
Bugzilla Link 13610
Resolution FIXED
Resolved on Aug 14, 2014 21:08
Version unspecified
OS Linux
CC @DougGregor,@efriedma-quic,@hubert-reinterpretcast

Extended Description

This code should not compile:

template decltype(char{sizeof(T)}) f(T); void f(...); auto x = f((char ()[1000])0);

... because SFINAE should reject the template due to the narrowing error, and thus we should pick the variadic and fail when auto type deduction deduces 'void'. But we don't, we pick the template, presumably because the narrowing case is a DefaultError Warning rather than actually being an Error.

hubert-reinterpretcast commented 10 years ago

I observed the behaviour requested in the report in r214060.

$ clang -cc1 -std=c++11 -x c++ pr13610.cc pr13610.cc:3:6: error: variable has incomplete type 'void' auto x = f((char (*)[1000])0); ^ 1 error generated.

efriedma-quic commented 12 years ago

presumably because the narrowing case is a DefaultError Warning rather than actually being an Error.

This analysis isn't right... the issue is that we don't ever re-analyze the list when it gets instantiated. Sema::BuildCXXTypeConstructExpr has a check for whether the arguments are type-dependent; maybe it needs to check value dependence as well?