Array Bounds [Was Re: Please see the following post. Some of you may know the answer. (sent to gcc@)]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 2023-08-09 09:56, Luís Carlos Carneiro Gonçalves via Gcc wrote:
It was a bug. I already corrected. It was an array with bad dimensions.

It was like:

int a[2];

a[2]=1;

******************

Corrected to:

int a[3];

********************

You should look at the option "-Warray-bounds" (https://gcc.gnu.org/onlinedocs/gcc-13.2.0/gcc/Warning-Options.html).

Sincerely,
S.


I updated the post in the Intel Forum.

Sorry. Thanks.

Luís Gonçalves




On 09/08/2023 15:50, Paul Smith wrote:
On Wed, 2023-08-09 at 11:14 +0200, Luís Carlos Carneiro Gonçalves via
Gcc wrote:
Without -O3 and -O2 the OpenCL gave consistently good results without
returning any error.

I think my code is Ok but I open to criticism.
By "has a bug" we don't necessarily mean something that is obviously
wrong and fails every time like trying to dereference a null pointer.

We mean, you are making an assumption about how the compiler will
compile your code, that is not guaranteed by the standard. Because
it's not guaranteed, when you enable optimizations the compiler is free
to rearrange things in ways you maybe don't expect, but are allowed by
the language definition.

If you are open to help me I can send all the sources.
I doubt anyone here has the time or energy to read and debug "all the
sources" for you.

If you reduce your code to a small example that shows the error, then
post that to the correct mailing list as Jonathan suggested. Then
someone may be able to point out your mistake.

Or, maybe it really is a bug in the optimizer.  Such things are very
rare but have been known to happen.  In my long experience as a
programmer, however, "the compiler has a bug" has NEVER been a winning
bet.




[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux