https://gcc.gnu.org/bugzilla/show_bug.cgi?id=117412
Bug ID: 117412 Summary: Bogus execution count for assignment with function call Product: gcc Version: 15.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: gcov-profile Assignee: unassigned at gcc dot gnu.org Reporter: wentaoz5 at illinois dot edu Target Milestone: --- How to reproduce: $ gcc --version gcc (GCC) 15.0.0 20240923 (experimental) Copyright (C) 2024 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. $ cat > test.c << 'EOF' int foo(long a) { return 0; }; struct Bar { int b; }; int main(void) { int x[100]; struct Bar y; int z; int a1; unsigned long a2; long long a3; *x = foo( a1*2); x[1] = foo( a2+1); y.b = foo( a3-3); return 0; } EOF $ gcc --coverage test.c -o test $ ./test $ gcov test $ cat test.c.gcov ... -: 15: 2: 16: *x = foo( 1: 17: a1*2); -: 18: 2: 19: x[1] = foo( 1: 20: a2+1); -: 21: 2: 22: y.b = foo( 1: 23: a3-3); -: 24: 1: 25: return 0; ... Line 16, 19 and 22 are reported to executed twice, which is hard to interpret. (Example reduced from https://github.com/apache/httpd/blob/2.4.62/server/util_filter.c#L138) These are the known conditions to trigger the behavior: 1. The argument is "somewhat complex": variable alone or constant alone won't trigger it 2. Function name and assignment is put in the first line; operator of the argument is put in the second line 3. Argument and parameter have different types 4. The return value is assigned to one of {subscript,dereference,struct member}