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

Reply via email to