[Bug middle-end/90238] Bogus warning from -Warray-bounds, triggered by zero-length character literal

2019-04-25 Thread rguenth at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90238

Richard Biener  changed:

   What|Removed |Added

   Keywords||diagnostic
 Status|UNCONFIRMED |ASSIGNED
   Last reconfirmed||2019-04-25
   Assignee|unassigned at gcc dot gnu.org  |rguenth at gcc dot 
gnu.org
 Ever confirmed|0   |1
   Severity|enhancement |normal

--- Comment #6 from Richard Biener  ---
Well, the warning code is confused by fortran passing &""[1], ignoring
the one-after-the-array case for

  /* Empty array.  */
  if (up_bound && tree_int_cst_equal (low_bound, up_bound_p1))
warned = warning_at (location, OPT_Warray_bounds,
 "array subscript %E is above array bounds of %qT",
 low_bound, artype);

not sure why this special-case was added here.  I think you can't create
this string literal with a C testcase (you always have the null termination).

I've added this check at r222146 possibly to rule out erratic behavior
in the anti-range handling case as part of the PR64277 fix.

[Bug middle-end/90238] Bogus warning from -Warray-bounds, triggered by zero-length character literal

2019-04-24 Thread townsend at astro dot wisc.edu
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90238

--- Comment #5 from Rich Townsend  ---
(In reply to Steve Kargl from comment #4)

> It's certainly confusing.  gfortran.info includes
> -Warray-bounds as a warning option, but there is no
> description for the option.  Grepping the gfortran
> source code found the error was not coming from the
> Fortran frontend.  Grepping the GCC source finds
> two instances of the warning string tree-vrp.c.  I
> know nothing of the middle-end code and how Fortran
> strings are represented.  Hopeefully, one the
> middle-end developers can provide a clue to
> suppressing the warning for Fortran strings.


That might be nice. In the meantime, the workaround consists of passing blank
strings ' ' instead of zero-length strings '', since the production code
behaves the same either way. And for the write statement,

write(*,*)

does the same as

write(*,*) ''

cheers,

Rich

[Bug middle-end/90238] Bogus warning from -Warray-bounds, triggered by zero-length character literal

2019-04-24 Thread sgk at troutmask dot apl.washington.edu
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90238

--- Comment #4 from Steve Kargl  ---
On Thu, Apr 25, 2019 at 12:41:10AM +, townsend at astro dot wisc.edu wrote:
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90238
> 
> --- Comment #3 from Rich Townsend  ---
> (In reply to kargl from comment #2)
> > -Warray-bounds is a generic GCC option, and is used in the
> > middle end for reporting warnings.  When you use this option
> > it does not recognize that a Fortran string is not an array.
> > So, it gleefully reports an array bounds option.  In other
> > words, either ignore the warning or stop using -Warray-bounds.
> 
> Thanks for the quick response, Steve. I think I can figure a workaround that
> allows us to continue using -Warray-bounds.
> 

It's certainly confusing.  gfortran.info includes
-Warray-bounds as a warning option, but there is no
description for the option.  Grepping the gfortran
source code found the error was not coming from the
Fortran frontend.  Grepping the GCC source finds
two instances of the warning string tree-vrp.c.  I
know nothing of the middle-end code and how Fortran
strings are represented.  Hopeefully, one the
middle-end developers can provide a clue to
suppressing the warning for Fortran strings.

[Bug middle-end/90238] Bogus warning from -Warray-bounds, triggered by zero-length character literal

2019-04-24 Thread townsend at astro dot wisc.edu
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90238

--- Comment #3 from Rich Townsend  ---
(In reply to kargl from comment #2)
> -Warray-bounds is a generic GCC option, and is used in the
> middle end for reporting warnings.  When you use this option
> it does not recognize that a Fortran string is not an array.
> So, it gleefully reports an array bounds option.  In other
> words, either ignore the warning or stop using -Warray-bounds.

Thanks for the quick response, Steve. I think I can figure a workaround that
allows us to continue using -Warray-bounds.

cheers,

Rich

[Bug middle-end/90238] Bogus warning from -Warray-bounds, triggered by zero-length character literal

2019-04-24 Thread kargl at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90238

kargl at gcc dot gnu.org changed:

   What|Removed |Added

   Priority|P3  |P5
 CC||kargl at gcc dot gnu.org
  Component|fortran |middle-end
   Severity|normal  |enhancement

--- Comment #2 from kargl at gcc dot gnu.org ---
-Warray-bounds is a generic GCC option, and is used in the
middle end for reporting warnings.  When you use this option
it does not recognize that a Fortran string is not an array.
So, it gleefully reports an array bounds option.  In other
words, either ignore the warning or stop using -Warray-bounds.