public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug middle-end/111669] New: bogus -Wnonnull in conditionally executed code
@ 2023-10-03  4:34 zfigura at codeweavers dot com
  2023-10-04  1:44 ` [Bug middle-end/111669] " xry111 at gcc dot gnu.org
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: zfigura at codeweavers dot com @ 2023-10-03  4:34 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 111669
           Summary: bogus -Wnonnull in conditionally executed code
           Product: gcc
           Version: 13.2.0
            Status: UNCONFIRMED
          Keywords: diagnostic
          Severity: normal
          Priority: P3
         Component: middle-end
          Assignee: unassigned at gcc dot gnu.org
          Reporter: zfigura at codeweavers dot com
  Target Milestone: ---

Created attachment 56032
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=56032&action=edit
reduced testcase, compile with -O2 -Werror=nonnull

Sorry about the rather useless title, but I can't really figure out what
actually triggers this error. It seems to depend on some arcane combination of
optimizations.

I was able to reduce this down to a pretty minimal test case, attached here. It
may be possible to reduce it further but I couldn't easily find a way.

The actual code that triggers this is here [1]. lstrcpyA() and lstrcatA() are
trivial wrappers around strcpy/strcat. The NULL comes from get_search_path() at
line 192. The offending strcpy/strcat will never be reached if
GetWindowsDirectoryA() returns nonzero, which it always should. However, gcc
triggers a -Wnonnull warning anyway.

Interestingly, the original Wine code only triggers the warning with
-march=bdver2 (or other values of -march), but the reduced testcase triggers it
with no -march flags.

[1]
https://source.winehq.org/git/wine.git/blob/HEAD:/dlls/krnl386.exe16/file.c#l639

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2023-10-05  6:14 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-10-03  4:34 [Bug middle-end/111669] New: bogus -Wnonnull in conditionally executed code zfigura at codeweavers dot com
2023-10-04  1:44 ` [Bug middle-end/111669] " xry111 at gcc dot gnu.org
2023-10-04  1:46 ` xry111 at gcc dot gnu.org
2023-10-04 15:44 ` zfigura at codeweavers dot com
2023-10-05  5:42 ` xry111 at gcc dot gnu.org
2023-10-05  5:48 ` xry111 at gcc dot gnu.org
2023-10-05  6:05 ` zfigura at codeweavers dot com
2023-10-05  6:14 ` xry111 at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).