<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/61662>61662</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
diagnose static variable/function references from gnu_inline functions
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
nickdesaulniers
</td>
</tr>
</table>
<pre>
GCC warns:
```c
static inline void foo (void) {}
__attribute__((gnu_inline))
extern inline void bar (void) { foo(); }
```
```
<source>:4:33: warning: 'foo' is static but used in inline function 'bar' which is not static
4 | extern inline void bar (void) { foo(); }
| ^~~
```
I asked around on #gcc and got the following feedback:
```
<jwakely>
probably because the static inline one can have a different definition in every TU (because C is crazy) and so you don't know which definition the extern inline one will actually call if not inlined
10:02 AM <pinskia>
https://gcc.gnu.org/PR39556
10:04 AM <ndesaulniers> Nick Desaulniers
jwakely: so I guess the issue would be if foo and bar were defined in different headers, theoretically foo could have a different definition in a third header, so a different TU could have different implementations of bar based on header inclusion order?
10:07 AM <pinskia>
the exact reference to the C standard is C99 6.7.4p3
10:10 AM <jakub>
still the basic C rules apply that even those inlined versions shouldn't refer to static vars or static functions because those can be different in each TU
10:11 AM
so, either make sure everything you call is also extern inline gnu_inline or similar, or make everything static inline
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJykVU2P2zYQ_TX0ZRBDImUrOvjgeOMihxZFkZwXFDWSGNOkwQ-77iG_vRhK649tih66ENaSQL558-Y9SoagB4u4YatPbPWykCmOzm-sVocOg0zGavRh0bruuvllt4OL9DYwsWXFCyu2bF1Ml5qeQ5RRK9DWaItwdrqD3jlg_CPdM94Aqz-x-mXenf-_vsoYvW5TxNdXxj8y_nGw6XXCYLyhKy_EPyN6-wTeSv8OnOplkIaJT3Av9Ub0549iF1zyCpn4zMS2YmIrBBPb3K22A90yXmfoGnSAuc82RUgBO9A3Wn2yKmpnaX0r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