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

Martin Sebor <msebor at gcc dot gnu.org> changed:

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

--- Comment #3 from Martin Sebor <msebor at gcc dot gnu.org> ---
As a data point, the invalid pointer subtraction is diagnosed at -O2 with the
patch submitted in November (but not reviewed):
https://gcc.gnu.org/pipermail/gcc-patches/2020-November/558775.html

$ gcc -O2 -Wall pr98880.c 
pr98880.c: In function ‘main’:
pr98880.c:25:20: warning: subtracting pointers to distinct objects
[-Wpointer-compare=]
   25 |   list.slh_first = (ssize_t)((char *)&ele - (char *)&list);
      |                    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
pr98880.c:22:16: note: operand 1 points to ‘ele’ declared here
   22 |   struct sh_le ele;
      |                ^~~
pr98880.c:21:16: note: operand 2 points to ‘list’ declared here
   21 |   struct sh_lq list;
      |                ^~~~
In file included from pr98880.c:2:
In function ‘sh_l_discard’,
    inlined from ‘main’ at pr98880.c:27:3:
pr98880.c:17:13: warning: ‘ele.sle_next’ is used uninitialized
[-Wuninitialized]
   17 |   assert(ele->sle_next == -1);
      |          ~~~^~~~~~~~~~
pr98880.c: In function ‘main’:
pr98880.c:22:16: note: ‘ele’ declared here
   22 |   struct sh_le ele;
      |                ^~~

Reply via email to