[Bug c++/108893] attribute access read_only

2023-02-25 Thread jg at jguk dot org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108893 --- Comment #11 from Jonny Grant --- As you say, in your quote from the manual, the access attribute read_only doesn't mean there will be any access at all. However, it doesn't seem to generate any warnings itself, maybe it is only for the optim

[Bug c++/108893] attribute access read_only

2023-02-25 Thread jg at jguk dot org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108893 --- Comment #10 from Jonny Grant --- (In reply to Andrew Pinski from comment #9) > (In reply to Jonny Grant from comment #8) > > So the caveat is this issue (2). I can't use attribute nonnull due to these > > optimizations that cannot be disable

[Bug c++/108893] attribute access read_only

2023-02-25 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108893 --- Comment #9 from Andrew Pinski --- (In reply to Jonny Grant from comment #8) > So the caveat is this issue (2). I can't use attribute nonnull due to these > optimizations that cannot be disabled. But you declare that argument cannot be null.

[Bug c++/108893] attribute access read_only

2023-02-25 Thread jg at jguk dot org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108893 --- Comment #8 from Jonny Grant --- (In reply to Andrew Pinski from comment #7) > access attribute says if it is access, then it will be that. It does not say > it MUST be accessed. That is what nonnull is for. > > >I didn't want to use __attri

[Bug c++/108893] attribute access read_only

2023-02-24 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108893 --- Comment #7 from Andrew Pinski --- access attribute says if it is access, then it will be that. It does not say it MUST be accessed. That is what nonnull is for. >I didn't want to use __attribute__((nonnull)) because the optimizer may use >

[Bug c++/108893] attribute access read_only

2023-02-24 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108893 Andrew Pinski changed: What|Removed |Added Resolution|DUPLICATE |INVALID --- Comment #6 from Andrew Pins

[Bug c++/108893] attribute access read_only

2023-02-24 Thread jg at jguk dot org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108893 --- Comment #5 from Jonny Grant --- Here is an example, no warnings during compilation. https://godbolt.org/z/h8E7r3Wf8 #include // Try get a build warning for nullptr dereference __attribute__ ((access (read_only, 1, 2))) void f(char * s, si

[Bug c++/108893] attribute access read_only

2023-02-22 Thread jg at jguk dot org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108893 --- Comment #4 from Jonny Grant --- My apologies, I had understood attribute access read_only was different from the attribute nonnull. So I filed a different report for this. I didn't want to use __attribute__((nonnull)) because the optimizer

[Bug c++/108893] attribute access read_only

2023-02-22 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108893 --- Comment #3 from Andrew Pinski --- (In reply to Jonny Grant from comment #0) > > void f(const char * const str) __attribute__((access(read_only, 1))); > void f(const char * const str) > { > __builtin_puts(str); > } > > int main() > { >

[Bug c++/108893] attribute access read_only

2023-02-22 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108893 Andrew Pinski changed: What|Removed |Added Status|UNCONFIRMED |RESOLVED Resolution|---

[Bug c++/108893] attribute access read_only

2023-02-22 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108893 --- Comment #1 from Andrew Pinski --- Isn't this the same as PR 108871 ? Also, the access attribute does not imply the attribute nonnull; it may be appropriate to add both attributes at the declaration of a function that unconditionally manipu