https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90994
Bug ID: 90994 Summary: Bogus Wmaybe-uninitialized with fnon-call-exceptions Product: gcc Version: 9.1.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: sagebar at web dot de Target Milestone: --- Created attachment 46517 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=46517&action=edit Minimal code that triggers the problem Using a branch-dependent return value in an assembly block with at least 5 line-line or `;` characters, where one of the branches gets triggered by some non-call-exception will result in values conditionally returned by only one of the paths to be considered uninitialized. This behavior seems to be _extremely_ specific, relying on any different factors having to come together to actually trigger the problem. (The attached file is a minimal code example that triggers this) To proove to yourself just how inconsistent this problem appears to be, try moving around the `asm`, or copying it after the second call to `readbyte` (or even just deleting one of its empty lines), and you will see that the warning will vanish. The provided configuration seems to be the only one for which the problem can be reproduced. The problem surfaces with `-O[1-4]` and `-O`, however doesn't with `-Og` or no `-O*` flag at all Removing `-fnon-call-exceptions` and adding an external function call or a conditional `throw`-statement within the `try`-block also seems to prevent the problem. Also note that the problem still happens when the assignment of `*presult` is moved after the `try`-block within `readbyte`, so-long as the read from `*(unsigned char volatile *)1234` stays inside the `try`-block. Compile the attached file with: `g++ -O2 -Wall -fnon-call-exceptions -c bogus.cc` I can personally confirm this problem for: - i686-elf-g++ (Version 9.1.0) - i686-pc-cygwin-g++ (Version 6.4.0) - i686-w64-mingw32-g++ (Version 7.4.0) - x86_64-pc-cygwin-g++ (Version 7.4.0) - x86_64-w64-mingw32-g++ (Version 7.4.0)