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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Target|riscv64-unknown-elf         |riscv64-unknown-elf
                   |                            |hppa*-*-* aarch64-*-*
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2022-01-28
     Ever confirmed|0                           |1

--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
strict alignment is causing the memcpy to have slightly different IR between
the targets.

I can reproduce the failure on aarch64 with -mstrict-align.
ubuntu@ubuntu:~/src/upstream-gcc-aarch64/gcc/objdir/gcc\# ./xgcc -B. t.c
-fanalyzer -Wanalyzer-too-complex -fanalyzer-call-summaries
ubuntu@ubuntu:~/src/upstream-gcc-aarch64/gcc/objdir/gcc\# ./xgcc -B. t.c
-fanalyzer -Wanalyzer-too-complex -fanalyzer-call-summaries  -mstrict-align
t.c: In function 'game_new':
t.c:31:1: warning: leak of 'tmp.word_state' [CWE-401] [-Wanalyzer-malloc-leak]
   31 | } /* { dg-bogus "leak" } */
      | ^
  'game_new': events 1-7
    |
    |   20 |         if ((tmp.word_state = malloc(wordlen+1)) == NULL)
    |      |            ~                  ^~~~~~~~~~~~~~~~~
    |      |            |                  |
    |      |            |                  (1) allocated here
    |      |            (2) assuming 'tmp.word_state' is non-NULL
    |      |            (3) following 'false' branch...
    |   21 |                 goto err;
    |   22 |         if ((rval = malloc(sizeof(*rval))) == NULL)
    |      |            ~        ~~~~~~~~~~~~~~~~~~~~~
    |      |            |        |
    |      |            |        (4) ...to here
    |      |            (5) following 'false' branch (when 'rval' is
non-NULL)...
    |   23 |                 goto err;
    |   24 |         memcpy(rval, &tmp, sizeof(*rval));
    |      |         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    |      |         |
    |      |         (6) ...to here
    |......
    |   31 | } /* { dg-bogus "leak" } */
    |      | ~
    |      | |
    |      | (7) 'tmp.word_state' leaks here; was allocated at (1)
    |

Reply via email to