[Bug c++/87742] [7/8/9 Regression] false warning: array subscript 3 is above array bounds of 'const std::type_info* const [3]'

2019-02-01 Thread frankhb1989 at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87742

frankhb1989 at gmail dot com changed:

   What|Removed |Added

 CC||frankhb1989 at gmail dot com

--- Comment #6 from frankhb1989 at gmail dot com ---
struct G
  {
 template operator X() const { return *this; }
  } g;

void w(unsigned o)
  {
extern int b[3];
void k(int);
switch (static_cast(o))
case 2:
  {
o != 2 ? nullptr : g;
k(b[o]);
  }
  }


The indeterminately recursive case is still certainly false positive, as there
is no rule rendering the behavior undefined, and the assertion in the message
can be logically inconsistent with the fact (when the condition value is
unsigned 2); it is definitely confusing. At least the wording can be improved
(e.g. replace "is" to "may be").

In this case, it should ideally warn on the infinite recursion itself, rather
than the subsequent caller site. Besides, the discarded-value expression here
can be totally optimized away before to reason whether the call is infinitely
recursive (though it may be difficult for specific optimizing implementations).

[Bug c++/87742] [7/8/9 Regression] false warning: array subscript 3 is above array bounds of 'const std::type_info* const [3]'

2019-02-01 Thread jakub at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87742

Jakub Jelinek  changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 Resolution|--- |INVALID

--- Comment #5 from Jakub Jelinek  ---
indeterminately recursive vs. infinite loop makes no difference.
Anyway, closing unless you come up with a testcase showing a real false
positive, this one is not it.

[Bug c++/87742] [7/8/9 Regression] false warning: array subscript 3 is above array bounds of 'const std::type_info* const [3]'

2018-12-06 Thread rguenth at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87742

Richard Biener  changed:

   What|Removed |Added

   Target Milestone|7.4 |7.5

[Bug c++/87742] [7/8/9 Regression] false warning: array subscript 3 is above array bounds of 'const std::type_info* const [3]'

2018-11-27 Thread lh_mouse at 126 dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87742

--- Comment #4 from Liu Hao  ---
In my real-world example,
0) the enclosing function is indeterminately recursive, but there is no
infinite loop, and
1) `o` has type `size_t`, which is a compile time constant because it is the
index of a type in a parameter pack;  because the number of elements in the
array is the `sizeof...` the parameter pack, in no case will it be out of
bound.

BTW the cast there is not to `unsigned char` but to an enum whose underlying
type is `unsigned char`. Using a wider integer type for it might resolve the
problem. Your information is invaluable.

[Bug c++/87742] [7/8/9 Regression] false warning: array subscript 3 is above array bounds of 'const std::type_info* const [3]'

2018-11-27 Thread jakub at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87742

Jakub Jelinek  changed:

   What|Removed |Added

 CC||jakub at gcc dot gnu.org

--- Comment #3 from Jakub Jelinek  ---
From my understanding, the warning is correct.
You have in the code essentially:
something b[3];
unsigned int o;
...
  switch ((unsigned char) o)
{
case 2:
  if (o == 2)
for (;;)
  ;
  b[o];
}
Thus, the b[o] array access is executed only if the low 8 bits of o are 2, but
the high 24 bits of o are not 0, so whenever it is executed, it is always out
of bounds access.
The infinite loop above is the result of:
F::G::operator int*
recursing infinitely.  So, in order to avoid the warning, you either want to
test all bits of o, rather than just the low 8 bits (i.e. avoid the cast to
bd), or do something with the conversion operator.
It of course could be just something introduced through creducing.

[Bug c++/87742] [7/8/9 Regression] false warning: array subscript 3 is above array bounds of 'const std::type_info* const [3]'

2018-11-21 Thread rguenth at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87742

Richard Biener  changed:

   What|Removed |Added

   Priority|P3  |P2

[Bug c++/87742] [7/8/9 Regression] false warning: array subscript 3 is above array bounds of 'const std::type_info* const [3]'

2018-10-31 Thread rguenth at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87742

Richard Biener  changed:

   What|Removed |Added

   Target Milestone|--- |7.4

[Bug c++/87742] [7/8/9 Regression] false warning: array subscript 3 is above array bounds of 'const std::type_info* const [3]'

2018-10-25 Thread msebor at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87742

Martin Sebor  changed:

   What|Removed |Added

 Status|UNCONFIRMED |NEW
   Last reconfirmed||2018-10-25
 CC||msebor at gcc dot gnu.org
Summary|False warning "warning: |[7/8/9 Regression] false
   |array subscript 3 is above  |warning: array subscript 3
   |array bounds of 'const  |is above array bounds of
   |std::type_info* const [3]'  |'const std::type_info*
   |"   |const [3]'
 Ever confirmed|0   |1

--- Comment #2 from Martin Sebor  ---
Confirmed.  The warning first appeared in GCC 5.0, with r217260:

r217260 | rguenth | 2014-11-09 06:27:00 -0500 (Sun, 09 Nov 2014) | 12 lines

2014-11-09  Richard Biener  

* match.pd: Add patterns convering two conversions in a row
from fold-const.c.
* fold-const.c (fold_unary_loc): Remove them here.
* tree-ssa-forwprop.c (combine_conversions): Likewise.
* genmatch.c (dt_node::gen_kids): Check whether we may
follow SSA use-def chains.

* g++.dg/cpp0x/constexpr-reinterpret1.C: XFAIL.
* gcc.dg/tree-ssa/pr21031.c: XFAIL.