<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=http://email.email.llvm.org/c/eJylVMuSmzAQ_Bq4TK2Lh186cDD7SHJPVc4SDKCsLLkkYbL5-ozANvZ6aw_ZKguMNDM93WpJmPqt-CaPqKExSplB6hYqU2OUbaHz_uCifBdlL_QbhmHRmloY5RfGtjTzl8aR2dWapeIbRBmj8QjSQ0sFHaC1xtJUpo1-8G8HBI_7g-Iegdu236P2IB1o44ETpnae0wz-OVh0ThpNmWCaUMDzV_yhPfVEk4wmAk5lQjGpQ8cBJIR33EGvX7UZNBy56hEwUPOd6dvuplIWoEfQAAgWfW_HUlPahJvQWETJU5TspueZQJQ_SqqSP4Pztq887CDalDSeorycQufaFAkzg_A1stiUEyikIYcyxzTeewPNVdxDQNkR4DsR8ucL1P3zuxmIuA0yObmXiltoel15UhUG6Ts4cMv36NHCuDFE90SkpCXn0I3yUmJICRb4PxHORWn-c21KolWCuNEludOlvUTdqBKSxYea_OreoDbEZuZLWyrC9pNTTt2dCA-dVHhxEi2H3houFR2BF_jZoQu-xWvpzKzqyVvlmKvrd16j2lV3Nvv9KZjctgtuC0CfRoQqnmJmDS89zEfnqp1JmQ-6Op-lU3MYjE-YLtAS1_WnE_HRcbh-xnWR1yxnPKat6owttKxeu57rlrG4t6q4vU1acmEvFuQy-lDqeH49HKz5jRX19yKd69HRn1W-3LC4K6o03TZ1xpc1500jcJ2LBtmqqTZinYomiRUXqFwRrcpo9RR_HVIWWUK004wlacLy5SJZb1dblrI0y9I6EVW0THBPFlmEOuFWjG0xlhR962hRSefdvEhGk61GPHfopVdYjPckdfnFq_K0HlYJNWSMJ_3eJ_HIshgp_gOPbOmc>53479</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
error: "non-type template argument is not a constant expression" is not consistent with constexpr function
</td>
</tr>
<tr>
<th>Labels</th>
<td>
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
nickhuang99
</td>
</tr>
</table>
<pre>
Given following code( https://www.godbolt.org/z/v9r5691bG ) , it gives error "non-type template argument is not a constant expression" of "takeInt(n)", complaining "n" has unknown value even though "takeInt" is constexpr returning value of "0".
template<int> struct A { };
constexpr int takeInt(int n){return 1;}
auto f(int n)-> A<takeInt(n)>;
However, similar function with parameter type of struct B passes compilation:
template<int> struct A { };
struct B{};
constexpr int takeB(B b){return 0;}
auto g(B b)-> A<takeB(b)>;
Why does parameter "b" as struct passes while "n" as int fails? These are parameter to function "takeB" and "takeInt" which is not template argument of "A". The template argument of "A" is the constexpr function expression "takeB(b)" and "takeInt(n)" which evaluates to be constexpr value "0".
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJylVE1zmzAQ_TVw2YmHD2NbBw4mTtLeO9OzgAXUyJJHEqbpr-8KbGPHnhzaGQuM9uPtezxR6vojfxNHVNBoKfUgVAuVrjFINtA5d7BBug2SV_oNw7BodV1q6RbatLTzh9aRmWzF4vINgoTRegbhoKWGFtAYbWgrUVo9uY8DgsP9QXKHwE3b71E5EBaUdsAJU1nHaQd_HwxaK7SiStCNb-D4O35XjmaiTUYbHqfSvplQfmIP4tM7bqFX70oPCo5c9gjoqblO92130ynx0COoBwSDrjdjq6lswo1oLYJoF0Tb6XomEKTPgrqkL2Cd6SsHWwjWBa1dkBZT6tybMmFm4J9GFutiAoXY11DlWMZ7p6G5ynvyKFsC_CRC-nKBur9-0wMRN14mK_ZCcgNNrypHqsIgXAcHbvgeHRoYXwzRPREpKGQt2lFeKvQl3gL_JsK5Ke1_rU1BtAoob3SJ7nRpL1k3qvji8qEmP7sPqDWxmfnSKy396yennKY7ER46IfHiJAr72RouJB2BV_jRofW-xWvp9KzqyVvFWKvqT16j3lV3Nvv9KZjctvVu80BfZvgujnJmDS8zzEfnapxJmQdTnc_SaTj0xidM62mV1_2nE_HoOFxfwzpPa5YyHjrhJObj6Sfn_OcH4BT3UUHzUHz07z37sDcyv_1itZTZlwtyMj1IeTzfng5G_8KKNHgV1vZo6U-WLtcs7PKswhr5ChuMeNys1siTdbpJmk2TVZwlGEpeorR5kBVBtgtFnkQkTJywKI5YulxEq022YTGLkySuo7IKlhHuyUQLD-y_m6HJxxnKvrUUlMTKzkGyomgV4rk_2b7TJleieu96rlrGwnHkfJz3L9b009A">