[Bug c/97261] New: gcc-10 produces invalid -Warray-bounds warning

2020-09-30 Thread gccbugs at dima dot secretsauce.net via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97261

Bug ID: 97261
   Summary: gcc-10 produces invalid -Warray-bounds warning
   Product: gcc
   Version: 10.1.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c
  Assignee: unassigned at gcc dot gnu.org
  Reporter: gccbugs at dima dot secretsauce.net
  Target Milestone: ---

Hi. I'm seeing gcc-10 flag a warning that I'm pretty sure is incorrect. gcc-9
and older did not warn about this (although that's probably because they
weren't looking for these kinds of problems).

Recipe:

1. save the attached as tst.c

2. gcc-10 -Wall -Wextra -Wno-unused-variable -fPIC -O3 -c -o tst.o tst.c

I see this:



tst.c: In function 'f':
tst.c:21:17: warning: array subscript -1 is outside array bounds of 'double[1]'
[-Warray-bounds]
   21 | const ab_t* ab = (ab_t*)(pb - 1);
  | ^~
tst.c:16:13: note: while referencing 'b'
   16 | double  b  = 4.;
  | ^



I believe this is false. Inside g(), ab->a is indeed out-of-bounds, but ab->b
is not. And I only use ab->b. Taking away -fPIC or -O3 makes the warning go
away. Making g() static makes it go away also.

I'm using gcc-10 from Debian. Package version 10.1.0-5.

Thanks!

[Bug c/97261] gcc-10 produces invalid -Warray-bounds warning

2020-09-30 Thread gccbugs at dima dot secretsauce.net via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97261

--- Comment #1 from Dima Kogan  ---
Created attachment 49294
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=49294&action=edit
Code to demo the issue

[Bug c/97261] gcc-10 produces invalid -Warray-bounds warning

2020-10-01 Thread gccbugs at dima dot secretsauce.net via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97261

--- Comment #3 from Dima Kogan  ---
Hi. Thanks for replying. I don't the warning that I'm claiming is bogus is
complaining about the points you raised. If it did, then making g() static or
building without -fPIC or -O3 wouldn't make the warning go away.

I have some questions about your analysis, if that's ok. g() doesn't know where
its ab argument came from, so how can the strict aliasing rules be violated?
The only reason the compiler knows anything at all here is that with -O3 it's
tracing the flow. With -O0, there's no warning. And g() may as well be in an
entirely different compilation unit, in which case it'd compile that unit with
no complaint at any optimization level.

Similarly, for the undefined behavior. If I have a function that takes some
double* x, then is it undefined behavior to refer to x[-1]? If not, then how is
this different?

Thanks.

[Bug c/114509] New: Infinite loop with openmp

2024-03-27 Thread gccbugs at dima dot secretsauce.net via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114509

Bug ID: 114509
   Summary: Infinite loop with openmp
   Product: gcc
   Version: 13.2.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c
  Assignee: unassigned at gcc dot gnu.org
  Reporter: gccbugs at dima dot secretsauce.net
  Target Milestone: ---

Created attachment 57827
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=57827&action=edit
Reduced reproducer

I git a bug in gcc 13.2 where an openmp loop causes he compiler to spin the
cpu, and never finish. I used creduce to minimize the test case, and the
reduced source is attached.

I'm running Debian GNU/Linux with gcc=4:13.2.0-1. I get an infinite loop with

  gcc-13 -fopenmp -c -o /dev/null /tmp/infinite-openmp.c

I happen to also have gcc-10 and gcc-11 installed, and they both produce an
infinite loop with that input as well.

Thanks

[Bug c/115379] New: -Wformat warning reports the wrong floating-point type

2024-06-06 Thread gccbugs at dima dot secretsauce.net via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115379

Bug ID: 115379
   Summary: -Wformat warning reports the wrong floating-point type
   Product: gcc
   Version: 14.1.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c
  Assignee: unassigned at gcc dot gnu.org
  Reporter: gccbugs at dima dot secretsauce.net
  Target Milestone: ---

Hi. I have this program:

#include 
void tst(void)
{
float x;
scanf("%f", x);
}

I compile and I see this:

$ gcc-14 -Wall -Wextra -c -o tst2 tst2.c
tst2.c: In function 'tst':
tst2.c:5:13: warning: format '%f' expects argument of type 'float *', but
argument 2 has type 'double' [-Wformat=]
5 | scanf("%f", x);
  |~^   ~
  | |   |
  | |   double
  | float *
...

Note that argument 2 has type "float", but the warning message says that it has
type "double". This is confusing. The actual bug is that it should be a
pointer, but it isn't.

This is gcc 14.1 from Debian version 14.1.0-1

Thanks

[Bug debug/78100] DWARF symbols for an array sometimes missing the array length

2024-01-05 Thread gccbugs at dima dot secretsauce.net via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78100

--- Comment #4 from Dima Kogan  ---
I just tried again, and I see that this bug has been fixed. I'm using

  gcc (Debian 13.2.0-2) 13.2.0

Should we close this report?