public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/106247] New: GCC12 warning in Eigen: array subscript is partly outside array bounds
@ 2022-07-10 16:11 fchelnokov at gmail dot com
2022-07-10 19:18 ` [Bug tree-optimization/106247] " pinskia at gcc dot gnu.org
` (6 more replies)
0 siblings, 7 replies; 8+ messages in thread
From: fchelnokov at gmail dot com @ 2022-07-10 16:11 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106247
Bug ID: 106247
Summary: GCC12 warning in Eigen: array subscript is partly
outside array bounds
Product: gcc
Version: 12.1.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: fchelnokov at gmail dot com
Target Milestone: ---
If one compiles the following program using Eigen 3.4.0:
#include <Eigen/Dense>
int main(){
Eigen::Array<double, 2, 2> a;
a.setRandom();
Eigen::Array<double, 3, 2> b;
b.col(0).tail(2) = a.col(1);
}
in GCC12 with command-line options: -std=c++20 -Wall -Wextra -pedantic-errors
-O2 -march=haswell
then a large error occurs ending with
/opt/compiler-explorer/gcc-12.1.0/lib/gcc/x86_64-linux-gnu/12.1.0/include/avxintrin.h:893:24:
warning: array subscript '__m256d_u[0]' is partly outside array bounds of
'Eigen::Array<double, 2, 2> [1]' [-Warray-bounds]
893 | return *(__m256d_u *)__P;
| ^~~
Similar errors occur with other -march options or other code using Eigen
library.
Everything is fine in GCC 11 or other compilers. Online demo:
https://gcc.godbolt.org/z/hT348GYo9
Is it Eigen or GCC bug? Related discussion:
https://stackoverflow.com/q/72871100/7325599
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug tree-optimization/106247] GCC12 warning in Eigen: array subscript is partly outside array bounds
2022-07-10 16:11 [Bug c++/106247] New: GCC12 warning in Eigen: array subscript is partly outside array bounds fchelnokov at gmail dot com
@ 2022-07-10 19:18 ` pinskia at gcc dot gnu.org
2022-07-10 19:26 ` pinskia at gcc dot gnu.org
` (5 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-07-10 19:18 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106247
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target| |x86_64-linux-gnu
Ever confirmed|0 |1
Status|UNCONFIRMED |WAITING
Last reconfirmed| |2022-07-10
Keywords| |diagnostic
Component|c++ |tree-optimization
--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Can you attach the preprocessed source?
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug tree-optimization/106247] GCC12 warning in Eigen: array subscript is partly outside array bounds
2022-07-10 16:11 [Bug c++/106247] New: GCC12 warning in Eigen: array subscript is partly outside array bounds fchelnokov at gmail dot com
2022-07-10 19:18 ` [Bug tree-optimization/106247] " pinskia at gcc dot gnu.org
@ 2022-07-10 19:26 ` pinskia at gcc dot gnu.org
2022-07-10 19:34 ` fchelnokov at gmail dot com
` (4 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-07-10 19:26 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106247
--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
the warning is correct in the sense the load is there in IR, though it looks
like it is dead (but only because b and a are unused):
array.7_137 = (long unsigned int) &MEM <double[6]> [(void *)&b + 8B];
_139 = array.7_137 >> 3;
_140 = -_139;
_141 = _140 & 3;
first_142 = (long int) _141;
_143 = MIN_EXPR <first_142, 2>;
_145 = 2 - _143;
alignedEnd_148 = _143;
goto <bb 4>; [100.00%]
<bb 3> [local count: 8655976563]:
index.12_166 = (long unsigned int) index_165;
_167 = index.12_166 * 8;
_168 = &MEM <double[4]> [(void *)&a + 16B] + _167;
_171 = &MEM <double[6]> [(void *)&b + 8B] + _167;
_172 = *_168;
MEM[(double &)_171] = _172;
index_173 = index_165 + 1;
<bb 4> [local count: 9725816346]:
# index_165 = PHI <0(2), index_173(3)>
if (_143 > index_165)
goto <bb 3>; [89.00%]
else
goto <bb 6>; [11.00%]
<bb 5> [local count: 8655976563]:
index.10_152 = (long unsigned int) index_151;
_153 = index.10_152 * 8;
_154 = &MEM <double[4]> [(void *)&a + 16B] + _153;
_155 = MEM[(__m256d_u * {ref-all})_154];
_158 = &MEM <double[6]> [(void *)&b + 8B] + _153;
MEM[(__m256d * {ref-all})_158] = _155;
index_159 = index_151 + 4;
<bb 6> [local count: 9725816346]:
# index_151 = PHI <_143(4), index_159(5)>
if (alignedEnd_148 > index_151)
goto <bb 5>; [89.00%]
else
goto <bb 8>; [11.00%]
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug tree-optimization/106247] GCC12 warning in Eigen: array subscript is partly outside array bounds
2022-07-10 16:11 [Bug c++/106247] New: GCC12 warning in Eigen: array subscript is partly outside array bounds fchelnokov at gmail dot com
2022-07-10 19:18 ` [Bug tree-optimization/106247] " pinskia at gcc dot gnu.org
2022-07-10 19:26 ` pinskia at gcc dot gnu.org
@ 2022-07-10 19:34 ` fchelnokov at gmail dot com
2022-07-10 19:37 ` pinskia at gcc dot gnu.org
` (3 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: fchelnokov at gmail dot com @ 2022-07-10 19:34 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106247
Fedor Chelnokov <fchelnokov at gmail dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |fchelnokov at gmail dot com
--- Comment #3 from Fedor Chelnokov <fchelnokov at gmail dot com> ---
Created attachment 53284
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=53284&action=edit
Preprocessed source
Preprocessed source is attached.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug tree-optimization/106247] GCC12 warning in Eigen: array subscript is partly outside array bounds
2022-07-10 16:11 [Bug c++/106247] New: GCC12 warning in Eigen: array subscript is partly outside array bounds fchelnokov at gmail dot com
` (2 preceding siblings ...)
2022-07-10 19:34 ` fchelnokov at gmail dot com
@ 2022-07-10 19:37 ` pinskia at gcc dot gnu.org
2022-08-02 4:51 ` skunk at iskunk dot org
` (2 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-07-10 19:37 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106247
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Ever confirmed|1 |0
Status|WAITING |UNCONFIRMED
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug tree-optimization/106247] GCC12 warning in Eigen: array subscript is partly outside array bounds
2022-07-10 16:11 [Bug c++/106247] New: GCC12 warning in Eigen: array subscript is partly outside array bounds fchelnokov at gmail dot com
` (3 preceding siblings ...)
2022-07-10 19:37 ` pinskia at gcc dot gnu.org
@ 2022-08-02 4:51 ` skunk at iskunk dot org
2022-09-04 6:06 ` mwd at md5i dot com
2022-09-04 6:08 ` mwd at md5i dot com
6 siblings, 0 replies; 8+ messages in thread
From: skunk at iskunk dot org @ 2022-08-02 4:51 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106247
Daniel Richard G. <skunk at iskunk dot org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |skunk at iskunk dot org
--- Comment #4 from Daniel Richard G. <skunk at iskunk dot org> ---
I am seeing what may be the same issue in a different context.
This is occurring in a proprietary C source codebase newly being compiled with
12.1.0, and unfortunately the problem goes away if I attempt to cut it down to
a minimal test case. Nevertheless, the actual issue is quite simple, and IMO
clear-cut.
(some names edited to protect the guilty)
In file included from /usr/include/string.h:375,
from foo.c:7:
In function 'function3',
inlined from 'function2' at foo.c:1206:5,
inlined from 'function1' at foo.c:2840:7:
foo.c:415:3: error: array subscript 'union <anonymous>[1]' is partly outside
array bounds of 'unsigned char[5]' [-Werror=array-bounds]
415 | memset(constraints,0,sizeof(char)*NB_CONSTRAINTS);
| ^~~~~~
foo.c: In function 'function1':
foo.c:380:17: note: at offset 4 into object 'constraints' of size 5
380 | unsigned char constraints[NB_CONSTRAINTS];
| ^~~~~~~~
cc1: all warnings being treated as errors
Curiously enough, I only see this issue in an i686 build. I don't get it on
x86-64. (Dropping -march=i686 does not help.)
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug tree-optimization/106247] GCC12 warning in Eigen: array subscript is partly outside array bounds
2022-07-10 16:11 [Bug c++/106247] New: GCC12 warning in Eigen: array subscript is partly outside array bounds fchelnokov at gmail dot com
` (4 preceding siblings ...)
2022-08-02 4:51 ` skunk at iskunk dot org
@ 2022-09-04 6:06 ` mwd at md5i dot com
2022-09-04 6:08 ` mwd at md5i dot com
6 siblings, 0 replies; 8+ messages in thread
From: mwd at md5i dot com @ 2022-09-04 6:06 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106247
Michael Duggan <mwd at md5i dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |mwd at md5i dot com
--- Comment #7 from Michael Duggan <mwd at md5i dot com> ---
I am working with some code that exhibits a similar problem. I've run creduce
on the preprocessed code to create an exemplar, which I have attached as
bug-mwd.cpp. Here's the relevant warnings from g++ 12.2.0 using '-std=c++14
-Wall -O2':
In member function ‘void i< <template-parameter-1-1> >::m(k*) [with ab = s]’,
inlined from ‘void i< <template-parameter-1-1> >::m(k*) [with ab = I]’ at
bug.cpp:25:26,
inlined from ‘i< <template-parameter-1-1> >::i(n) [with n = I*; ab = I]’ at
bug.cpp:23:39,
inlined from ‘am I::u()’ at bug.cpp:48:3:
bug.cpp:27:5: warning: array subscript ‘i<s>::k {aka s}[0]’ is partly outside
array bounds of ‘unsigned char [40]’ [-Warray-bounds]
27 | e(p->aa);
| ^~~~~~~~
bug.cpp: In member function ‘am I::u()’:
bug.cpp:48:9: note: object of size 40 allocated by ‘operator new’
48 | o(new I);
| ^
The example is convoluted, I am afraid. One very strange bit is that if I
change the 'o's in 'class I' to, say, 'p', I get a completely different error.
If you think this is unrelated, let me know, and I will submit a new bug
report.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug tree-optimization/106247] GCC12 warning in Eigen: array subscript is partly outside array bounds
2022-07-10 16:11 [Bug c++/106247] New: GCC12 warning in Eigen: array subscript is partly outside array bounds fchelnokov at gmail dot com
` (5 preceding siblings ...)
2022-09-04 6:06 ` mwd at md5i dot com
@ 2022-09-04 6:08 ` mwd at md5i dot com
6 siblings, 0 replies; 8+ messages in thread
From: mwd at md5i dot com @ 2022-09-04 6:08 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106247
--- Comment #8 from Michael Duggan <mwd at md5i dot com> ---
Created attachment 53533
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=53533&action=edit
Reduced bug exemplar
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2022-09-04 6:08 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-10 16:11 [Bug c++/106247] New: GCC12 warning in Eigen: array subscript is partly outside array bounds fchelnokov at gmail dot com
2022-07-10 19:18 ` [Bug tree-optimization/106247] " pinskia at gcc dot gnu.org
2022-07-10 19:26 ` pinskia at gcc dot gnu.org
2022-07-10 19:34 ` fchelnokov at gmail dot com
2022-07-10 19:37 ` pinskia at gcc dot gnu.org
2022-08-02 4:51 ` skunk at iskunk dot org
2022-09-04 6:06 ` mwd at md5i dot com
2022-09-04 6:08 ` mwd at md5i dot com
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).