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

    <tr>
        <th>Summary</th>
        <td>
            clang incorrectly permits odr-use
        </td>
    </tr>

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

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

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

<pre>
    > § 6.3 One-definition rule
> If a local entity is odr-used in a declarative region which is not odr-usable, the program is ill-formed.

This example below seems ~similar to the one in https://eel.is/c++draft/basic.def.odr#example-2 but it's not rejected by clang.

```
$ cat ~/tmp/odr.cpp 
void foo(auto x) {
  struct F {
    void bar() { x = 0; }
  };
}

```

```
$ clang++ --version
clang version 18.1.8
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /local/mnt/workspace/install/clang-latest/bin

$ clang++ -c ~/tmp/odr.cpp -std=c++20 ; echo $?
0

```

gcc does reject this:
```
$ g++ -c ~/tmp/odr.cpp -std=c++20
/usr2/bcain/tmp/odr.cpp: In member function ‘void foo(auto:1)::F::bar()’:
/usr2/bcain/tmp/odr.cpp:3:18: error: use of parameter from containing function
    3 |     void bar() { x = 0; }
      |                  ^
/usr2/bcain/tmp/odr.cpp:1:15: note: ‘auto:1 x’ declared here
    1 | void foo(auto x) {
      |          ~~~~~^
$ g++ --version
g++ (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0
Copyright (C) 2021 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.

```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyUVU1v2zgT_jX0ZSBBIi1bPvjgOBFeA32bIkkPe1pQ5MjiliIFknLsS377gpKcj2673RKJZHE--MwHn-Heq6NB3JLihhS3Cz6E1rotN9LZjkm-qK28bAm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