<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/118063>118063</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            [clang] Constexpr function of a function parameter cannot be used in a constant expression
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            clang
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          StefanPaulet
      </td>
    </tr>
</table>

<pre>
    The following code compiles on gcc, but fails on msvc and clang:
``` C++
template <unsigned int N>
struct array {
    constexpr auto size() const -> unsigned int {
        return N;
    }
};

constexpr auto foo(array<5> const& arr) {
    return array<arr.size()>{}.size();
}

constexpr auto bar(array<5> arr) {
 return array<arr.size()>{}.size();
}

int main()
{
    array<5> arr {};
    static_assert(arr.size() == 5);
    static_assert(foo(arr) == 5);
 static_assert(bar(arr) == 5);
}
```
https://godbolt.org/z/q1xajW1Gq

However, if `size` is made static, msvc also compiles:
https://godbolt.org/z/Tfqe5E9z8

The problem seems to be with `arr` being passed by reference, as passing by value also get accepted.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJykVMuOqzgQ_ZpiU-rIGMJjwSKddGZWo5HmSrMcGVMQXxmbtk368fUjQzqZjiLN4kZIEfU65xRVJbxXgyFqYPsM20Mi5nCyrvkrUC_Mn2LWFJLWdh_NjxNhb7W2b8oMKG1HKO04KU0ercFBSuB7bOeAvVB6sY3-LFGYDqUWZoBsB2wHBVsf3AN_jg_bBRonLQIhZPvZLHw6VCbgH5C9ANv54GYZUDgnPhDKmIKIKK3xgd4nh2IOFr36JOAV8Hr14BNkL_it3i03_hyF2ZkI8mWF8hAplofVBGx3h9FbC7xaiEC230aAJQJ4EelF7BvGpf5XtHBuc-MYlZXPUB6-2Z4v8I-wW-Husb9D_ipe7NAolLk4o-dLyj0qrrVunfNBBCX_Ed6TCyvN_wAhZAfIDri9gj7KuTb3ccZ9-LUfD8Mvqr6mDdjuFMLk4xDyI_DjYLvW6rCxbgB-_AR-fE3fxc-_099e1278bt_oTC4OteoRCrbIKRgqj6Po6MIn-tc5195eN2Kd9f9D_NG_0val_qxWxLhhk7OtphE90egxfnXCNxVOkUCUWjBsKS7gFPvQYfuBjnpyZCRFKsIvnhjRfuBZ6JlWZgMFFFLSFKjbJF2TdXVWi4SatMx4VRS8YsmpSamvCkkku7ousjIve1HmRd_mFZUZq9NENZzxPE15zco8z9mG0j6lkpPc8pTyPIWc0SiU3mh9HqPWRHk_U5OmFSuyRIuWtF-ODefrWeA83h3XxISndh485EwrH_ytRFBBLxdqzdgecH_djX42Mihr0PYobm-TcGKkQA6lMMaG2MjZL3cAxbq0wgSMJch7ZU0yO93cfTEVTnO7kXYEfoxkLn9Pk7M_SQbgx0WcB3686Ds3_N8AAAD__xdxoIk">