* [Bug c++/43555] wrong address calculation of multidimensional variable-length array element
2010-03-28 15:35 [Bug c++/43555] New: wrong address calculation of multidimensional variable-length array element skir50 at gmail dot com
@ 2010-03-28 15:50 ` sezeroz at gmail dot com
2010-03-28 16:33 ` rguenth at gcc dot gnu dot org
` (14 subsequent siblings)
15 siblings, 0 replies; 17+ messages in thread
From: sezeroz at gmail dot com @ 2010-03-28 15:50 UTC (permalink / raw)
To: gcc-bugs
------- Comment #1 from sezeroz at gmail dot com 2010-03-28 15:49 -------
Happens with 4.3.0 and 4.4.4 on i686-pc-linux, too. Reproduced the problem with
g++ only at -O0. -O1 and higher output the wanted result.
--
sezeroz at gmail dot com changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |sezeroz at gmail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43555
^ permalink raw reply [flat|nested] 17+ messages in thread
* [Bug c++/43555] wrong address calculation of multidimensional variable-length array element
2010-03-28 15:35 [Bug c++/43555] New: wrong address calculation of multidimensional variable-length array element skir50 at gmail dot com
2010-03-28 15:50 ` [Bug c++/43555] " sezeroz at gmail dot com
@ 2010-03-28 16:33 ` rguenth at gcc dot gnu dot org
2010-04-09 21:01 ` [Bug c++/43555] [4.3/4.4/4.5/4.6 Regression] " pinskia at gcc dot gnu dot org
` (13 subsequent siblings)
15 siblings, 0 replies; 17+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2010-03-28 16:33 UTC (permalink / raw)
To: gcc-bugs
------- Comment #2 from rguenth at gcc dot gnu dot org 2010-03-28 16:33 -------
Confirmed. The problem seems to be gimplification of type sizes where
we end up putting the size calculation stmts into the conditional block,
a place not dominating the 2nd stmt where we re-use it:
x2d = (double[0:(unsigned int) (SAVE_EXPR <(<unnamed-signed:32>) nx +
-1>)][0:(unsigned int) SAVE_EXPR <D.2820>] *) x1d;
if (choice != 0) goto <D.2817>; else goto <D.2818>;
<D.2817>:
ny.2 = ny;
D.2820 = ny.2 + -1;
D.2821 = (unsigned int) D.2820;
D.2822 = D.2821 + 1;
D.2823 = &(*x2d)[1]{lb: 0 sz: D.2822 * 8}[0];
D.2824 = (int) D.2823;
x1d.3 = (int) x1d;
D.2826 = D.2824 - x1d.3;
D.2827 = D.2826 /[ex] 8;
delta = (long unsigned int) D.2827;
goto <D.2828>;
<D.2818>:
D.2829 = (unsigned int) D.2820;
D.2830 = D.2829 + 1;
D.2831 = &(*x2d)[1]{lb: 0 sz: D.2830 * 8}[0];
D.2832 = (int) D.2831;
x1d.4 = (int) x1d;
D.2834 = D.2832 - x1d.4;
D.2835 = D.2834 /[ex] 8;
delta = (long unsigned int) D.2835;
<D.2828>:
printf (&"Choice: %d, Delta: %ld\n"[0], choice, delta);
also see how the type-sizes in the cast are not gimplified. Thus, if
we'd have gimplified type-sizes when gimplifying
<<cleanup_point <<< Unknown tree: expr_stmt
(void) (x2d = (double[0:(unsigned int) (SAVE_EXPR <(<unnamed-signed:32>) nx +
-1>)][0:(unsigned int) (SAVE_EXPR <(<unnamed-signed:32>) ny + -1>)] *) x1d) >>>
>>;
it all would have worked out. The C frontend seems to be lucky because
it decomposes the address difference internally:
if (choice != 0)
{
delta = (long unsigned int) (((int) ((double *) x2d + (unsigned int)
SAVE_EXPR <ny> * 8) - (int) x1d) /[ex] 8);
}
else
{
delta = (long unsigned int) (((int) ((double *) x2d + (unsigned int)
SAVE_EXPR <ny> * 8) - (int) x1d) /[ex] 8);
}
but even changing the testcase to sth different shows that for C we
properly gimplify type-sizes of casts.
--
rguenth at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Ever Confirmed|0 |1
Keywords| |wrong-code
Known to fail| |4.3.4 4.4.2 4.5.0
Last reconfirmed|0000-00-00 00:00:00 |2010-03-28 16:33:10
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43555
^ permalink raw reply [flat|nested] 17+ messages in thread
* [Bug c++/43555] [4.3/4.4/4.5/4.6 Regression] wrong address calculation of multidimensional variable-length array element
2010-03-28 15:35 [Bug c++/43555] New: wrong address calculation of multidimensional variable-length array element skir50 at gmail dot com
2010-03-28 15:50 ` [Bug c++/43555] " sezeroz at gmail dot com
2010-03-28 16:33 ` rguenth at gcc dot gnu dot org
@ 2010-04-09 21:01 ` pinskia at gcc dot gnu dot org
2010-04-10 13:37 ` hjl dot tools at gmail dot com
` (12 subsequent siblings)
15 siblings, 0 replies; 17+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2010-04-09 21:01 UTC (permalink / raw)
To: gcc-bugs
------- Comment #3 from pinskia at gcc dot gnu dot org 2010-04-09 21:01 -------
This used to work in 4.1.x.
--
pinskia at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
GCC build triplet|i686-pc-cygwin |
GCC host triplet|i686-pc-cygwin |
GCC target triplet|i686-pc-cygwin |
Known to work| |4.1.3
Summary|wrong address calculation of|[4.3/4.4/4.5/4.6 Regression]
|multidimensional variable- |wrong address calculation of
|length array element |multidimensional variable-
| |length array element
Target Milestone|--- |4.3.5
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43555
^ permalink raw reply [flat|nested] 17+ messages in thread
* [Bug c++/43555] [4.3/4.4/4.5/4.6 Regression] wrong address calculation of multidimensional variable-length array element
2010-03-28 15:35 [Bug c++/43555] New: wrong address calculation of multidimensional variable-length array element skir50 at gmail dot com
` (2 preceding siblings ...)
2010-04-09 21:01 ` [Bug c++/43555] [4.3/4.4/4.5/4.6 Regression] " pinskia at gcc dot gnu dot org
@ 2010-04-10 13:37 ` hjl dot tools at gmail dot com
2010-04-10 13:39 ` hjl dot tools at gmail dot com
` (11 subsequent siblings)
15 siblings, 0 replies; 17+ messages in thread
From: hjl dot tools at gmail dot com @ 2010-04-10 13:37 UTC (permalink / raw)
To: gcc-bugs
------- Comment #4 from hjl dot tools at gmail dot com 2010-04-10 13:37 -------
It is caused by revision 117493:
http://gcc.gnu.org/ml/gcc-cvs/2006-10/msg00158.html
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43555
^ permalink raw reply [flat|nested] 17+ messages in thread
* [Bug c++/43555] [4.3/4.4/4.5/4.6 Regression] wrong address calculation of multidimensional variable-length array element
2010-03-28 15:35 [Bug c++/43555] New: wrong address calculation of multidimensional variable-length array element skir50 at gmail dot com
` (3 preceding siblings ...)
2010-04-10 13:37 ` hjl dot tools at gmail dot com
@ 2010-04-10 13:39 ` hjl dot tools at gmail dot com
2010-04-15 14:05 ` rguenth at gcc dot gnu dot org
` (10 subsequent siblings)
15 siblings, 0 replies; 17+ messages in thread
From: hjl dot tools at gmail dot com @ 2010-04-10 13:39 UTC (permalink / raw)
To: gcc-bugs
------- Comment #5 from hjl dot tools at gmail dot com 2010-04-10 13:39 -------
(In reply to comment #4)
> It is caused by revision 117493:
>
> http://gcc.gnu.org/ml/gcc-cvs/2006-10/msg00158.html
>
Maybe C++ frontend needs similar adjustment.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43555
^ permalink raw reply [flat|nested] 17+ messages in thread
* [Bug c++/43555] [4.3/4.4/4.5/4.6 Regression] wrong address calculation of multidimensional variable-length array element
2010-03-28 15:35 [Bug c++/43555] New: wrong address calculation of multidimensional variable-length array element skir50 at gmail dot com
` (4 preceding siblings ...)
2010-04-10 13:39 ` hjl dot tools at gmail dot com
@ 2010-04-15 14:05 ` rguenth at gcc dot gnu dot org
2010-05-22 19:00 ` rguenth at gcc dot gnu dot org
` (9 subsequent siblings)
15 siblings, 0 replies; 17+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2010-04-15 14:05 UTC (permalink / raw)
To: gcc-bugs
--
rguenth at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Priority|P3 |P2
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43555
^ permalink raw reply [flat|nested] 17+ messages in thread
* [Bug c++/43555] [4.3/4.4/4.5/4.6 Regression] wrong address calculation of multidimensional variable-length array element
2010-03-28 15:35 [Bug c++/43555] New: wrong address calculation of multidimensional variable-length array element skir50 at gmail dot com
` (5 preceding siblings ...)
2010-04-15 14:05 ` rguenth at gcc dot gnu dot org
@ 2010-05-22 19:00 ` rguenth at gcc dot gnu dot org
2010-05-27 18:32 ` jason at gcc dot gnu dot org
` (8 subsequent siblings)
15 siblings, 0 replies; 17+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2010-05-22 19:00 UTC (permalink / raw)
To: gcc-bugs
------- Comment #6 from rguenth at gcc dot gnu dot org 2010-05-22 18:13 -------
GCC 4.3.5 is being released, adjusting target milestone.
--
rguenth at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|4.3.5 |4.3.6
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43555
^ permalink raw reply [flat|nested] 17+ messages in thread
* [Bug c++/43555] [4.3/4.4/4.5/4.6 Regression] wrong address calculation of multidimensional variable-length array element
2010-03-28 15:35 [Bug c++/43555] New: wrong address calculation of multidimensional variable-length array element skir50 at gmail dot com
` (6 preceding siblings ...)
2010-05-22 19:00 ` rguenth at gcc dot gnu dot org
@ 2010-05-27 18:32 ` jason at gcc dot gnu dot org
2010-05-27 18:36 ` jason at gcc dot gnu dot org
` (7 subsequent siblings)
15 siblings, 0 replies; 17+ messages in thread
From: jason at gcc dot gnu dot org @ 2010-05-27 18:32 UTC (permalink / raw)
To: gcc-bugs
------- Comment #7 from jason at gcc dot gnu dot org 2010-05-27 18:32 -------
This doesn't work with my 4.1 tree. Or with 3.2 for that matter. It does work
with 2.95.
--
jason at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Known to work|4.1.3 |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43555
^ permalink raw reply [flat|nested] 17+ messages in thread
* [Bug c++/43555] [4.3/4.4/4.5/4.6 Regression] wrong address calculation of multidimensional variable-length array element
2010-03-28 15:35 [Bug c++/43555] New: wrong address calculation of multidimensional variable-length array element skir50 at gmail dot com
` (7 preceding siblings ...)
2010-05-27 18:32 ` jason at gcc dot gnu dot org
@ 2010-05-27 18:36 ` jason at gcc dot gnu dot org
2010-05-27 18:40 ` jason at gcc dot gnu dot org
` (6 subsequent siblings)
15 siblings, 0 replies; 17+ messages in thread
From: jason at gcc dot gnu dot org @ 2010-05-27 18:36 UTC (permalink / raw)
To: gcc-bugs
------- Comment #8 from jason at gcc dot gnu dot org 2010-05-27 18:36 -------
Subject: Bug 43555
Author: jason
Date: Thu May 27 18:36:22 2010
New Revision: 159938
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=159938
Log:
PR c++/43555
* decl.c (grokdeclarator) [cdk_pointer et al]: Force evaluation of
anonymous VLA size.
Added:
branches/gcc-4_5-branch/gcc/testsuite/g++.dg/ext/vla9.C
Modified:
branches/gcc-4_5-branch/gcc/cp/ChangeLog
branches/gcc-4_5-branch/gcc/cp/decl.c
branches/gcc-4_5-branch/gcc/testsuite/ChangeLog
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43555
^ permalink raw reply [flat|nested] 17+ messages in thread
* [Bug c++/43555] [4.3/4.4/4.5/4.6 Regression] wrong address calculation of multidimensional variable-length array element
2010-03-28 15:35 [Bug c++/43555] New: wrong address calculation of multidimensional variable-length array element skir50 at gmail dot com
` (8 preceding siblings ...)
2010-05-27 18:36 ` jason at gcc dot gnu dot org
@ 2010-05-27 18:40 ` jason at gcc dot gnu dot org
2010-05-27 19:01 ` jason at gcc dot gnu dot org
` (5 subsequent siblings)
15 siblings, 0 replies; 17+ messages in thread
From: jason at gcc dot gnu dot org @ 2010-05-27 18:40 UTC (permalink / raw)
To: gcc-bugs
------- Comment #9 from jason at gcc dot gnu dot org 2010-05-27 18:39 -------
Subject: Bug 43555
Author: jason
Date: Thu May 27 18:39:28 2010
New Revision: 159939
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=159939
Log:
PR c++/43555
* decl.c (grokdeclarator) [cdk_pointer et al]: Force evaluation of
anonymous VLA size.
Added:
trunk/gcc/testsuite/g++.dg/ext/vla9.C
Modified:
trunk/gcc/cp/ChangeLog
trunk/gcc/cp/decl.c
trunk/gcc/testsuite/ChangeLog
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43555
^ permalink raw reply [flat|nested] 17+ messages in thread
* [Bug c++/43555] [4.3/4.4/4.5/4.6 Regression] wrong address calculation of multidimensional variable-length array element
2010-03-28 15:35 [Bug c++/43555] New: wrong address calculation of multidimensional variable-length array element skir50 at gmail dot com
` (9 preceding siblings ...)
2010-05-27 18:40 ` jason at gcc dot gnu dot org
@ 2010-05-27 19:01 ` jason at gcc dot gnu dot org
2010-05-27 19:10 ` jason at gcc dot gnu dot org
` (4 subsequent siblings)
15 siblings, 0 replies; 17+ messages in thread
From: jason at gcc dot gnu dot org @ 2010-05-27 19:01 UTC (permalink / raw)
To: gcc-bugs
------- Comment #10 from jason at gcc dot gnu dot org 2010-05-27 19:00 -------
Subject: Bug 43555
Author: jason
Date: Thu May 27 19:00:33 2010
New Revision: 159942
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=159942
Log:
PR c++/43555
* decl.c (grokdeclarator) [cdk_pointer et al]: Force evaluation of
anonymous VLA size.
Added:
branches/gcc-4_4-branch/gcc/testsuite/g++.dg/ext/vla9.C
Modified:
branches/gcc-4_4-branch/gcc/cp/ChangeLog
branches/gcc-4_4-branch/gcc/cp/decl.c
branches/gcc-4_4-branch/gcc/testsuite/ChangeLog
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43555
^ permalink raw reply [flat|nested] 17+ messages in thread
* [Bug c++/43555] [4.3/4.4/4.5/4.6 Regression] wrong address calculation of multidimensional variable-length array element
2010-03-28 15:35 [Bug c++/43555] New: wrong address calculation of multidimensional variable-length array element skir50 at gmail dot com
` (10 preceding siblings ...)
2010-05-27 19:01 ` jason at gcc dot gnu dot org
@ 2010-05-27 19:10 ` jason at gcc dot gnu dot org
2010-05-27 19:55 ` jakub at gcc dot gnu dot org
` (3 subsequent siblings)
15 siblings, 0 replies; 17+ messages in thread
From: jason at gcc dot gnu dot org @ 2010-05-27 19:10 UTC (permalink / raw)
To: gcc-bugs
------- Comment #11 from jason at gcc dot gnu dot org 2010-05-27 19:10 -------
Fixed for 4.4.6. I'm inclined not to apply the change to 4.3 just in case it
causes problems somehow, but I could be convinced otherwise.
--
jason at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution| |FIXED
Target Milestone|4.3.6 |4.4.6
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43555
^ permalink raw reply [flat|nested] 17+ messages in thread
* [Bug c++/43555] [4.3/4.4/4.5/4.6 Regression] wrong address calculation of multidimensional variable-length array element
2010-03-28 15:35 [Bug c++/43555] New: wrong address calculation of multidimensional variable-length array element skir50 at gmail dot com
` (11 preceding siblings ...)
2010-05-27 19:10 ` jason at gcc dot gnu dot org
@ 2010-05-27 19:55 ` jakub at gcc dot gnu dot org
2010-05-27 20:02 ` jason at gcc dot gnu dot org
` (2 subsequent siblings)
15 siblings, 0 replies; 17+ messages in thread
From: jakub at gcc dot gnu dot org @ 2010-05-27 19:55 UTC (permalink / raw)
To: gcc-bugs
--
jakub at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|4.4.6 |4.4.5
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43555
^ permalink raw reply [flat|nested] 17+ messages in thread
* [Bug c++/43555] [4.3/4.4/4.5/4.6 Regression] wrong address calculation of multidimensional variable-length array element
2010-03-28 15:35 [Bug c++/43555] New: wrong address calculation of multidimensional variable-length array element skir50 at gmail dot com
` (12 preceding siblings ...)
2010-05-27 19:55 ` jakub at gcc dot gnu dot org
@ 2010-05-27 20:02 ` jason at gcc dot gnu dot org
2010-05-27 20:04 ` jason at gcc dot gnu dot org
2010-05-27 20:55 ` jakub at gcc dot gnu dot org
15 siblings, 0 replies; 17+ messages in thread
From: jason at gcc dot gnu dot org @ 2010-05-27 20:02 UTC (permalink / raw)
To: gcc-bugs
------- Comment #12 from jason at gcc dot gnu dot org 2010-05-27 20:02 -------
Subject: Bug 43555
Author: jason
Date: Thu May 27 20:02:10 2010
New Revision: 159945
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=159945
Log:
PR c++/43555
* decl.c (grokdeclarator) [cdk_pointer et al]: Force evaluation of
anonymous VLA size.
Added:
branches/gcc-4_3-branch/gcc/testsuite/g++.dg/ext/vla9.C
Modified:
branches/gcc-4_3-branch/gcc/cp/ChangeLog
branches/gcc-4_3-branch/gcc/cp/decl.c
branches/gcc-4_3-branch/gcc/testsuite/ChangeLog
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43555
^ permalink raw reply [flat|nested] 17+ messages in thread
* [Bug c++/43555] [4.3/4.4/4.5/4.6 Regression] wrong address calculation of multidimensional variable-length array element
2010-03-28 15:35 [Bug c++/43555] New: wrong address calculation of multidimensional variable-length array element skir50 at gmail dot com
` (13 preceding siblings ...)
2010-05-27 20:02 ` jason at gcc dot gnu dot org
@ 2010-05-27 20:04 ` jason at gcc dot gnu dot org
2010-05-27 20:55 ` jakub at gcc dot gnu dot org
15 siblings, 0 replies; 17+ messages in thread
From: jason at gcc dot gnu dot org @ 2010-05-27 20:04 UTC (permalink / raw)
To: gcc-bugs
------- Comment #13 from jason at gcc dot gnu dot org 2010-05-27 20:04 -------
On reflection, I went ahead and applied it to 4.3 since it only affects VLA
code anyway.
--
jason at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Known to fail|4.3.4 4.4.2 4.5.0 |3.0 3.2 3.3 4.3.4 4.4.2
| |4.5.0
Known to work| |2.95
Target Milestone|4.4.5 |4.3.7
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43555
^ permalink raw reply [flat|nested] 17+ messages in thread
* [Bug c++/43555] [4.3/4.4/4.5/4.6 Regression] wrong address calculation of multidimensional variable-length array element
2010-03-28 15:35 [Bug c++/43555] New: wrong address calculation of multidimensional variable-length array element skir50 at gmail dot com
` (14 preceding siblings ...)
2010-05-27 20:04 ` jason at gcc dot gnu dot org
@ 2010-05-27 20:55 ` jakub at gcc dot gnu dot org
15 siblings, 0 replies; 17+ messages in thread
From: jakub at gcc dot gnu dot org @ 2010-05-27 20:55 UTC (permalink / raw)
To: gcc-bugs
--
jakub at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|4.3.7 |4.3.6
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43555
^ permalink raw reply [flat|nested] 17+ messages in thread