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

    <tr>
        <th>Summary</th>
        <td>
            Clang issues incorrect diagnostic when we have a catch blocks that catch both const char* and char*
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            clang:frontend,
            clang:diagnostics
      </td>
    </tr>

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

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

<pre>
    Given the following C++ code:

```cpp
#include <iostream>

int main() {
    const char arr[4] = "abc";

   try {
     throw arr;
   } catch (char *p) {
      std::cout << "char*\n";
   } catch (const char *p) {
      std::cout << "const char*\n";
 }
}
```

clang issues the following diagnostic: https://godbolt.org/z/j38xbs5oE

```console
<source>:10:19: warning: exception of type 'const char *' will be caught by earlier handler [-Wexceptions]
   } catch (const char *p) {
 ^
<source>:8:13: note: for type 'char *'
   } catch (char *p) {
 ^
1 warning generated.
ASM generation compiler returned: 0
<source>:10:19: warning: exception of type 'const char *' will be caught by earlier handler [-Wexceptions]
   } catch (const char *p) {
 ^
<source>:8:13: note: for type 'char *'
   } catch (char *p) {
            ^
1 warning generated.
Execution build compiler returned: 0
Program returned: 0
const char*
```

We we can see from the full output is incorrect. It is likely because the wording in [expr.throw p2](https://eel.is/c++draft/expr.throw#2) has a defect which says that we throw `arr` the type should be `char *` but this it not intended and it subject of [Defect Report 2699](https://wg21.link/cwg2699) which is not public yet.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzsVU2T4jYQ_TXNpWsoI2GMDz7wMaRySFUqOexZltq2doTk0scw5NenZBhgdiep3ZxDUUbVQurX73U_ixB0b4kaKLdQ7mcixcH5Jgyi0y-z1qlz84t-JYtxIOycMe6kbY87YFtgW5ROEfANFHso3p-r4vKV43iNMK6tNEkRAt9pF6IncQT-_HhM24hHoS2wNbAaodpe4oiI0tkQUQ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