https://gcc.gnu.org/bugzilla/show_bug.cgi?id=127043
Bug ID: 127043
Summary: Warning when function marked
__attribute__((externally_visible)) uses
__attribute__((assume(statement)))
Product: gcc
Version: 16.2.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: k2k at drgrin dot dev
Target Milestone: ---
Warning triggered for every function marked with
__attribute__((externally_visible)) when the statement in assume requires
reading from memory.
Minimal example:
$ cat > test.c << _EOF_
__attribute__((externally_visible)) void f (int *p)
{
__attribute__((assume (*p > 0)));
}
_EOF_
$ gcc -O1 -c test.c
test.c:3:3: warning: 'externally_visible' attribute have effect only on public
objects [-Wattributes]
3 | __attribute__((assume (*p > 0)));
| ^~~~~~~~~~~~~
Triggered with -O1 or higher.
The same for:
$ gcc-14 --version
gcc-14 (Gentoo 14.3.1_p20260604 p6) 14.3.1 20260604
$ gcc --version
gcc (Gentoo 15.3.0 p8) 15.3.0
$ gcc-16 --version
gcc-16 (Gentoo 16.2.0 p3) 16.2.0