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

    <tr>
        <th>Summary</th>
        <td>
            [Clang] errors with "conflicting types for" functions whose declarations only differ by return type constness
        </td>
    </tr>

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

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

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

<pre>
    ```
$ cat a.c
int qwe(void);
const int qwe(void);
$ cc -c a.c
a.c:2:11: error: conflicting types for 'qwe'
    2 | const int qwe(void);
      | ^
a.c:1:5: note: previous declaration is here
    1 | int qwe(void);
      |     ^
1 error generated.
$ gcc -Wall -pedantic -c a.c
$ cc --version
Debian clang version 18.0.0 (++20231231112334+c7c912cff945-1~exp1~20231231112352.433)
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /bin
$ gcc --version
gcc (Debian 12.2.0-14) 12.2.0
Copyright (C) 2022 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
```
(and the same with gcc 13.2.0-7)

In [a Draft](https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3096.pdf), 6.7.6.3 Function declarators, Semantics, 4, I see
> If, in the declaration "**T D1**", **D1** has the form
>        **D** `(` parameter-type-listopt `)` attribute-specifier-sequenceopt
> and the type specified for *ident* in the declaration "**T D**" is "*derived-declarator-type-list T*", then the type specified for *ident* is "*derived-declarator-type-list* function returning the unqualified, non-atomic
version of *T*". The optional attribute specifier sequence appertains to the function type.

This appears to imply that the types for both declarations are processed thusly (pardon the C++-like syntax):
```cpp
remove_atomic<remove_cv<int>> qwe(void);
remove_atomic<remove_cv<const int>> qwe(void);
```
yielding
```c
int qwe(void);
int qwe(void);
```
which is identical.

([Original report](https://101010.pl/@sebastian@jittr.click/111770387762063846))
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyMVktv2z4S_zT0ZSBBoiQ_Dj74EWMDdJsicbHYU0FRI4upTKokZcd76GdfDCXHSdB_WyeAxOGP8_jNgxLOqYNGXLJizYrtRPS-MXapRamehfxfi2ds1aQ01WXJpsn4n2xZsmI8Byk8iFgOAqU9_Dgj4_OTURXjC5athx1ptPPwz_tBlYRI3pTRS7biLFulKctWgNYaSy_S6LpV0it9AH_p0EFtLDA-C6pnw2kAAA5stoE_mYbwIyQr7t6aJqsFGdTGIz07iydlegcVylZY4ZXRoBw0aPGmKw26_sZeeF5tpkOAcECNVnis4hszB6LmP6JtIeqwEtqr91Rd2YtOaJ0yepBusVRCg2yFPsC4A-k8TuIEGJ8zvmZ8zROepTxL05RnWc74Ws7kIuWyrhd5EaU_8aVLf74FFTzOs4wCCkb2wh7QEzsv8-m3aR51MmqV7l-ig-5HSGNRVHA0FbaBRuPUy7B1r50XbYvVVoXUMr4rlf4Q-PuoSMT4fAwu5TGPkyjNGV-MiwG2Md3FqkPjCbyhXZ5wDjuLCE-m9mdhEXam11VII-MbuNcyvnqsHCW2JrQb0Sxbg0ME35CstxJD3UnTXagSpdGVIlUuBthTSZCGzw-DxrOwVmh_ISXaeMAT6nD833ePm3-tPu9X6_tP9_v_grGwu99_vnt6gt3DI6zgy-pxf7_5-mn1CF--Pn55eLq7FsbHZpwLXQ3eiSPCWfkm8JdmgaLZa8qu1AMr1gK2VtSeFVvG5433nWPZivEd47vz-RybDnXkfBUbe2B89-xlyvjOSc4JcCDaCcf4rjLSMb7TWbKYxl1VkzW-gWk8i6dxBrtey9Au19Yx1tH-Ex5DOYdFHrJAJI-OZndwX5NQ6RDY275j5MOK8dUetunwFkQbGBZXITTChcO1sceb3vE3YkcokcnnbJpAJ6w4okcb0YSJWuW86fwAWBBAeG9V2XuMXIdS1Qpt5PBHj1qi6fzN0DUppAeu2GocWStVofZk-g8RvgZIRTVsVGjVCavoxujNV9jf6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