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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jakub at gcc dot gnu.org

--- Comment #24 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
(In reply to Martin Sebor from comment #1)
> The warning is by design.

That just means the design is bad.  Especially in the embedded world, using
memory mapped IO at fixed addresses is very common and we really shouldn't
force
people to pessimize their code by adding volatile on the pointers etc.

>  Its purpose is to detect invalid accesses at
> non-zero offsets to null pointers, like in the memset call below:
> 
>   struct S { int a, b[4]; };
> 
>   void f (struct S *p)
>   {
>     if (p) return;
>     memset (p->b, 0, 4 * sizeof p->b);
>   }
> 
> For now, I recommend suppressing the warning either by #pragma GCC
> diagnostic or by making the pointer volatile.  In the future, providing an
> attribute to annotate constant addresses with (or extending the io()
> attribute supported by some targets to all targets) might be another way to
> avoid it.

Then perhaps just add some flag on the INTEGER_CSTs created from folding
&ptr->member into constant (seems currently that happens during {,e}vrp and
dom) and only in the spots you warn if the INTEGER_CST has that flag set?

Reply via email to