[Bug middle-end/35903] false Warray-bounds warning when passing quoted string to function strcmp(arg,"no");

2019-08-16 Thread msebor at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=35903

Martin Sebor  changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 CC||msebor at gcc dot gnu.org
 Resolution|--- |WORKSFORME

--- Comment #12 from Martin Sebor  ---
I haven't been able to reproduce the false positive with any of the test cases
here, with -O2 or -O3 and with -funsigned-chars or without.  Since there have
been updates in almost a decade I'm going to close this.  If someone still can
reproduce it please either reopen this bug or open a new one and include a test
case that reproduce the warning and compiles without errors.  Also mention the
target for which you are compiling -- at least one of the attachments looks
like it's from a powerpc system.

[Bug middle-end/35903] false Warray-bounds warning when passing quoted string to function strcmp(arg,"no");

2018-11-09 Thread egallager at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=35903

--- Comment #11 from Eric Gallager  ---
(In reply to Manuel López-Ibáñez from comment #4)
> (In reply to comment #3)
> > This bug has no changed for months, I think it is still active.
> 
> Newer higher priority bugs often make us forget about old inactive bugs.
> Going through old bugs and testing whether they still exist in a recent GCC
> would be extremely helpful.
> 

This is what I've been doing ever since I got my bugzilla account

[Bug middle-end/35903] false Warray-bounds warning when passing quoted string to function strcmp(arg,no);

2010-02-19 Thread manu at gcc dot gnu dot org


--- Comment #9 from manu at gcc dot gnu dot org  2010-02-19 23:56 ---
This is not an uninitialized issue. 

The reason this requires -O2 is that -Warray-bounds requires VRP to warn. The
gimple output already looks quite different.

-funsigned-char:

   D.1565:
[pr35903.i : 309:15] D.1567 = __s1D.796 + 3;
[pr35903.i : 309:15] D.1568 = [pr35903.i : 309] *D.1567;
[pr35903.i : 310:11] D.1569 = (intD.0) D.1568;
[pr35903.i : 318:12] D.1570 = [pr35903.i : 311] [pr35903.i : 311]
AA[0] + 3;
[pr35903.i : 318:12] D.1571 = [pr35903.i : 318] *D.1570;
[pr35903.i : 310:11] D.1572 = (intD.0) D.1571;
[pr35903.i : 308:10] __resultD.797 = D.1569 - D.1572;
D.1566:
D.1556:

-fsigned-char

 D.1566:
[pr35903.i : 309:15] D.1568 = __s1D.796 + 3;
[pr35903.i : 309:15] D.1569 = [pr35903.i : 309] *D.1568;
[pr35903.i : 310:11] D.1570 = (intD.0) D.1569;
[pr35903.i : 311:12] D.1540 = (const unsigned charD.10 *) [pr35903.i :
318] AA;
[pr35903.i : 318:12] D.1571 = D.1540 + 3;
[pr35903.i : 318:12] D.1572 = [pr35903.i : 318] *D.1571;
[pr35903.i : 310:11] D.1573 = (intD.0) D.1572;
[pr35903.i : 308:10] __resultD.797 = D.1570 - D.1573;
D.1567:
D.1557:
D.1547:


-- 

manu at gcc dot gnu dot org changed:

   What|Removed |Added

OtherBugsDependingO|24639   |
  nThis||
Summary|false uninitialized warning |false Warray-bounds warning
   |when passing quoted string  |when passing quoted string
   |to function |to function
   |strcmp(arg,no);   |strcmp(arg,no);


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35903



[Bug middle-end/35903] false Warray-bounds warning when passing quoted string to function strcmp(arg,no);

2010-02-19 Thread manu at gcc dot gnu dot org


--- Comment #10 from manu at gcc dot gnu dot org  2010-02-20 00:19 ---
Reduced testcase:

extern int strlen (__const char *__s);
int echo (int);
int main(int argc, char **argv)
{
  echo (({ int __s1_len, __s2_len;
  (__builtin_constant_p (argv[0])  __builtin_constant_p (AA) 
   (__s1_len = strlen (argv[0]), __s2_len = strlen (AA),
(!((int)(const void *)((argv[0]) + 1) - (int)(const void *)(argv[0]) == 1)
 || __s1_len = 4)

(!((int)(const void *)((AA) + 1) - (int)(const void *)(AA) == 1)
 || __s2_len = 4))
   ? 1
   : (__builtin_constant_p (argv[0])
   ((int)(const void *)((argv[0]) + 1) - (int)(const void *)(argv[0]) ==
1)
   (__s1_len = strlen (argv[0]), __s1_len  4)
  ? 1
  : (__builtin_constant_p (AA)  ((int)(const void *)((AA) + 1) -
(int)(const void *)(AA) == 1)
  (__s2_len = strlen (AA), __s2_len  4)
 ? (__builtin_constant_p (argv[0])
 ((int)(const void *)((argv[0]) + 1) - (int)(const void
*)(argv[0]) == 1)
? 1
: (({
  __const unsigned char *__s1 = (__const unsigned char *) (__const
char *) (argv[0]);
  register int __result = __s1[0] - ((__const unsigned char *)
(__const char *) (AA))[0];
  if (__s2_len  0  __result == 0)
{
  __result = (__s1[1] - ((__const unsigned char *) (__const
char *) (AA))[1]);
  if (__s2_len  1  __result == 0)
{
  __result = (__s1[2] - ((__const unsigned char *) (__const
char *) (AA))[2]);
  if (__s2_len  2  __result == 0)
__result = (__s1[3] - ((__const  unsigned  char  *)
(__const  char  *) (AA))[3]);
}
}
  __result;
})))
 : 0))); }));

  return 0;
}


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35903