https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85546

            Bug ID: 85546
           Summary: GCC assumes volatile asm block returns same value in
                    loop
           Product: gcc
           Version: 7.3.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: be11f157cd19c4a2ba1e9c70a38b1a74 at protonmail dot com
  Target Milestone: ---

Created attachment 44027
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=44027&action=edit
Code that triggers the bug

This code works correctly when compiled with no optimizations. When
optimizations are enabled the while loop in the input() function becomes an
infinite loop. GCC seems to be assuming that the return value of io() cannot
change between iterations of the loop despite the asm block within io() being
declared "volatile".

The program is tested with this input file:

1
1

Reply via email to