[PATCH] D104285: [analyzer] Retrieve value by direct index from list initialization of constant array declaration.

Chris Hamilton via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Jun 25 13:00:24 PDT 2021


chrish_ericsson_atx added a comment.

While this patch resolves the issue captured in https://bugs.llvm.org/show_bug.cgi?id=50604, it actually introduces a *new* bug.  Perhaps this is what you were alluding to?  Here's a reproducer which doesn't fail on main (with or without the problematic b30521c28a4d <https://reviews.llvm.org/rGb30521c28a4dc1b94d793385e4144ede5822b2c1> commit), but it *does* fail with this proposed patch:

  eahcmrh at seroius03977[21:50][repo/eahcmrh/ltebb]$ cat ~/pr50604-newbug.c 
  static float const dt[12] =
  {
    0.0000, 0.0235, 0.0470, 0.0706, 0.0941, 0.1176,
    0.1411, 0.1646, 0.1881, 0.2117, 0.2352, 0.2587
  };
  void foo(float s)
  {
    (void)( s + dt[0]) ;
  }
  eahcmrh at seroius03977[21:57][repo/eahcmrh/ltebb]$ /proj/bbi/eahcmrh/arcpatch-D104285/compiler-clang/bin/clang -Xanalyzer -analyzer-werror --analyze ~/pr50604-newbug.c 
  /home/eahcmrh/pr50604-newbug.c:8:13: error: The right operand of '+' is a garbage value [core.UndefinedBinaryOperatorResult]
    (void)( s + dt[0]) ;
              ^ ~~~~~
  1 error generated.

I'll upload this reproducer to the bug report as well.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D104285/new/

https://reviews.llvm.org/D104285



More information about the cfe-commits mailing list