public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/108871] New: attribute nonnull does not spot nullptr O2 and above when function inlined
@ 2023-02-21 14:53 jg at jguk dot org
  2023-02-21 14:54 ` [Bug c++/108871] " jg at jguk dot org
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: jg at jguk dot org @ 2023-02-21 14:53 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 108871
           Summary: attribute nonnull does not spot nullptr O2 and above
                    when function inlined
           Product: gcc
           Version: 12.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: jg at jguk dot org
  Target Milestone: ---

With Optimizations level 1 it still works.

https://godbolt.org/z/6axdfchr8

-fanalyzer -std=c++23 -O3 -Wnonnull -Wall
-Wno-analyzer-use-of-uninitialized-value


#include <string>

std::string make_std_string(const char * const str) __attribute__ ((nonnull));

std::string make_std_string(const char * const str)
{
    return std::string(str);
}

int main()
{
    const char * a = NULL;
    std::string result = make_std_string(a);
    __builtin_puts(result.c_str());
}

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

end of thread, other threads:[~2023-03-03 20:54 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-21 14:53 [Bug c++/108871] New: attribute nonnull does not spot nullptr O2 and above when function inlined jg at jguk dot org
2023-02-21 14:54 ` [Bug c++/108871] " jg at jguk dot org
2023-02-22  8:31 ` [Bug ipa/108871] " rguenth at gcc dot gnu.org
2023-02-22 20:31 ` pinskia at gcc dot gnu.org
2023-02-23 12:28 ` jg at jguk dot org
2023-02-23 16:21 ` redi at gcc dot gnu.org
2023-02-23 16:39 ` jakub at gcc dot gnu.org
2023-02-24 22:35 ` jg at jguk dot org
2023-03-03 20:54 ` jg at jguk dot 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).