public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/108893] New: attribute access read_only
@ 2023-02-22 20:27 jg at jguk dot org
  2023-02-22 20:30 ` [Bug c++/108893] " pinskia at gcc dot gnu.org
                   ` (10 more replies)
  0 siblings, 11 replies; 12+ messages in thread
From: jg at jguk dot org @ 2023-02-22 20:27 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 108893
           Summary: attribute access read_only
           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: ---

could attribute access read_only give a build warning about this nullptr
dereference? This example compiles, and then gives SEGV when run.

Following on from gcc-help mailing list discussion I tried this out
https://gcc.gnu.org/pipermail/gcc-help/2023-February/142280.html


void f(const char * const str) __attribute__((access(read_only, 1)));
void f(const char * const str)
{
    __builtin_puts(str);
}

int main()
{
    const char * a = nullptr;
    f(a);
}


https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html

Tested on trunk in C++
https://godbolt.org/z/rc8G6bePq

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

end of thread, other threads:[~2023-02-26  0:03 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-22 20:27 [Bug c++/108893] New: attribute access read_only jg at jguk dot org
2023-02-22 20:30 ` [Bug c++/108893] " pinskia at gcc dot gnu.org
2023-02-22 20:31 ` pinskia at gcc dot gnu.org
2023-02-22 20:33 ` pinskia at gcc dot gnu.org
2023-02-22 20:54 ` jg at jguk dot org
2023-02-24 23:42 ` jg at jguk dot org
2023-02-24 23:44 ` pinskia at gcc dot gnu.org
2023-02-24 23:47 ` pinskia at gcc dot gnu.org
2023-02-25 23:39 ` jg at jguk dot org
2023-02-25 23:47 ` pinskia at gcc dot gnu.org
2023-02-26  0:01 ` jg at jguk dot org
2023-02-26  0:03 ` 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).