https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97196
Bug ID: 97196 Summary: Difference in output between no optimization and -O2, triggered by a variable wrapped in parentheses in the RHS of the assignment operator Product: gcc Version: 9.3.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: m.bartelsman.mejia at student dot rug.nl Target Milestone: --- Created attachment 49266 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=49266&action=edit Source and preprocessed files GCC version: 9.3.0 System: Ubuntu 20.04.1 LTS on WSL2 on Win10 x86_64, and at least one other, unknown, system. GCC Options: gcc -std=c99 -pedantic -Wall -o a.out *.c gcc -std=c99 -pedantic -Wall -o a.out *.c -O2 How to reproduce: On both versions run: $ a.out $ 2000 Non -O2 will yield `2002 3`, while -O2 will yield `2002 0` Compiler output: Only on -O2 version: palindromicSums.c: In function ‘main’: palindromicSums.c:34:3: warning: ignoring return value of ‘scanf’, declared with attribute warn_unused_result [-Wunused-result] 34 | scanf("%d", &n); | ^~~~~~~~~~~~~~~