public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug middle-end/14236] New: dynamically-sized arrays break alloca()
@ 2004-02-21 10:36 aoliva at gcc dot gnu dot org
2004-02-21 10:37 ` [Bug middle-end/14236] " aoliva at gcc dot gnu dot org
` (9 more replies)
0 siblings, 10 replies; 11+ messages in thread
From: aoliva at gcc dot gnu dot org @ 2004-02-21 10:36 UTC (permalink / raw)
To: gcc-bugs
If the same block contains a dynamically-sized array and alloca() calls, we
release the memory allocated for both at the end of the block. Oops. This
occurs in GCC 3.3.3, 3.4 CVS, mainline CVS and tree-ssa CVS (oh, and GCC 2.96 as
well, but you don't want to know about that :-)
Optimization doesn't seem to affect it.
--
Summary: dynamically-sized arrays break alloca()
Product: gcc
Version: 3.3.2
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: middle-end
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: aoliva at gcc dot gnu dot org
CC: gcc-bugs at gcc dot gnu dot org
GCC build triplet: i686-pc-linux-gnu
GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14236
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug middle-end/14236] dynamically-sized arrays break alloca()
2004-02-21 10:36 [Bug middle-end/14236] New: dynamically-sized arrays break alloca() aoliva at gcc dot gnu dot org
@ 2004-02-21 10:37 ` aoliva at gcc dot gnu dot org
2004-02-21 10:56 ` jsm at polyomino dot org dot uk
` (8 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: aoliva at gcc dot gnu dot org @ 2004-02-21 10:37 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From aoliva at gcc dot gnu dot org 2004-02-21 10:37 -------
Created an attachment (id=5780)
--> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=5780&action=view)
Testcase that exposes the problem.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14236
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug middle-end/14236] dynamically-sized arrays break alloca()
2004-02-21 10:36 [Bug middle-end/14236] New: dynamically-sized arrays break alloca() aoliva at gcc dot gnu dot org
2004-02-21 10:37 ` [Bug middle-end/14236] " aoliva at gcc dot gnu dot org
@ 2004-02-21 10:56 ` jsm at polyomino dot org dot uk
2004-02-22 0:06 ` aoliva at gcc dot gnu dot org
` (7 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: jsm at polyomino dot org dot uk @ 2004-02-21 10:56 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From jsm at polyomino dot org dot uk 2004-02-21 10:56 -------
Subject: Re: New: dynamically-sized arrays break
alloca()
On Sat, 21 Feb 2004, aoliva at gcc dot gnu dot org wrote:
> If the same block contains a dynamically-sized array and alloca() calls, we
> release the memory allocated for both at the end of the block. Oops. This
> occurs in GCC 3.3.3, 3.4 CVS, mainline CVS and tree-ssa CVS (oh, and GCC 2.96 as
> well, but you don't want to know about that :-)
So where's the bug in this? It looks just like what the documentation
says:
# (If you use both variable-length arrays and
# @code{alloca} in the same function, deallocation of a variable-length array
# will also deallocate anything more recently allocated with @code{alloca}.)
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14236
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug middle-end/14236] dynamically-sized arrays break alloca()
2004-02-21 10:36 [Bug middle-end/14236] New: dynamically-sized arrays break alloca() aoliva at gcc dot gnu dot org
2004-02-21 10:37 ` [Bug middle-end/14236] " aoliva at gcc dot gnu dot org
2004-02-21 10:56 ` jsm at polyomino dot org dot uk
@ 2004-02-22 0:06 ` aoliva at gcc dot gnu dot org
2004-02-23 0:40 ` pinskia at gcc dot gnu dot org
` (6 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: aoliva at gcc dot gnu dot org @ 2004-02-22 0:06 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From aoliva at gcc dot gnu dot org 2004-02-22 00:06 -------
Well, yes, it is documented, but that doesn't make it right (although I know
people that will qualify documented bugs as features :-). IMHO, it's still
wrong, especially now that variable-length arrays are standard. Sure, alloca is
non-standard, but it still doesn't feel right.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14236
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug middle-end/14236] dynamically-sized arrays break alloca()
2004-02-21 10:36 [Bug middle-end/14236] New: dynamically-sized arrays break alloca() aoliva at gcc dot gnu dot org
` (2 preceding siblings ...)
2004-02-22 0:06 ` aoliva at gcc dot gnu dot org
@ 2004-02-23 0:40 ` pinskia at gcc dot gnu dot org
2004-04-06 1:06 ` pinskia at gcc dot gnu dot org
` (5 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-02-23 0:40 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From pinskia at gcc dot gnu dot org 2004-02-23 00:40 -------
On at least PPC (and most likely all other targets), alloca and VLAs is done by growing the stack and the
restorting it (for the VLA case) at the end of the block. I do not think there is anyways around this
problem ("bug", "feature").
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14236
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug middle-end/14236] dynamically-sized arrays break alloca()
2004-02-21 10:36 [Bug middle-end/14236] New: dynamically-sized arrays break alloca() aoliva at gcc dot gnu dot org
` (3 preceding siblings ...)
2004-02-23 0:40 ` pinskia at gcc dot gnu dot org
@ 2004-04-06 1:06 ` pinskia at gcc dot gnu dot org
2004-04-22 17:50 ` pinskia at gcc dot gnu dot org
` (4 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-04-06 1:06 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From pinskia at gcc dot gnu dot org 2004-04-06 01:05 -------
Maybe there is a need for more docs.
--
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Ever Confirmed| |1
Keywords| |documentation
Last reconfirmed|0000-00-00 00:00:00 |2004-04-06 01:05:58
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14236
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug middle-end/14236] dynamically-sized arrays break alloca()
2004-02-21 10:36 [Bug middle-end/14236] New: dynamically-sized arrays break alloca() aoliva at gcc dot gnu dot org
` (4 preceding siblings ...)
2004-04-06 1:06 ` pinskia at gcc dot gnu dot org
@ 2004-04-22 17:50 ` pinskia at gcc dot gnu dot org
2005-02-10 23:45 ` pinskia at gcc dot gnu dot org
` (3 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-04-22 17:50 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From pinskia at gcc dot gnu dot org 2004-04-22 17:37 -------
Some how I missed the patch but here it is:
<http://gcc.gnu.org/ml/gcc-patches/2004-02/msg02092.html>.
--
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |patch
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14236
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug middle-end/14236] dynamically-sized arrays break alloca()
2004-02-21 10:36 [Bug middle-end/14236] New: dynamically-sized arrays break alloca() aoliva at gcc dot gnu dot org
` (5 preceding siblings ...)
2004-04-22 17:50 ` pinskia at gcc dot gnu dot org
@ 2005-02-10 23:45 ` pinskia at gcc dot gnu dot org
2005-02-10 23:57 ` sds at gnu dot org
` (2 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-02-10 23:45 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From pinskia at gcc dot gnu dot org 2005-02-10 20:53 -------
*** Bug 19881 has been marked as a duplicate of this bug. ***
--
What |Removed |Added
----------------------------------------------------------------------------
CC| |sds at gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14236
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug middle-end/14236] dynamically-sized arrays break alloca()
2004-02-21 10:36 [Bug middle-end/14236] New: dynamically-sized arrays break alloca() aoliva at gcc dot gnu dot org
` (6 preceding siblings ...)
2005-02-10 23:45 ` pinskia at gcc dot gnu dot org
@ 2005-02-10 23:57 ` sds at gnu dot org
2005-02-14 20:23 ` aoliva at gcc dot gnu dot org
2005-02-14 20:26 ` sds at gnu dot org
9 siblings, 0 replies; 11+ messages in thread
From: sds at gnu dot org @ 2005-02-10 23:57 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From sds at gnu dot org 2005-02-10 21:13 -------
(In reply to comment #3)
> Well, yes, it is documented, but that doesn't make it right (although I know
> people that will qualify documented bugs as features :-). IMHO, it's still
> wrong, especially now that variable-length arrays are standard. Sure, alloca is
> non-standard, but it still doesn't feel right.
why is this not right?
I find this perfectly natural.
--
What |Removed |Added
----------------------------------------------------------------------------
CC| |bruno at clisp dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14236
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug middle-end/14236] dynamically-sized arrays break alloca()
2004-02-21 10:36 [Bug middle-end/14236] New: dynamically-sized arrays break alloca() aoliva at gcc dot gnu dot org
` (7 preceding siblings ...)
2005-02-10 23:57 ` sds at gnu dot org
@ 2005-02-14 20:23 ` aoliva at gcc dot gnu dot org
2005-02-14 20:26 ` sds at gnu dot org
9 siblings, 0 replies; 11+ messages in thread
From: aoliva at gcc dot gnu dot org @ 2005-02-14 20:23 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From aoliva at gcc dot gnu dot org 2005-02-14 16:29 -------
Yes, it is natural, once you look into the mechanisms used to implement the
features. However, if you focus on the definitions:
- memory allocated for dynamic-sized arrays is released at the time the array
goes out of scope
- memory allocated with alloca() is released at the time the function that calls
alloca() returns
then there's no reason to expect dynamic-sized arrays and alloca() to interfere
with each other.
I agree that implementing them in such a way that they don't interfere is
probably impossible with a single stack, but that still doesn't make it right.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14236
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug middle-end/14236] dynamically-sized arrays break alloca()
2004-02-21 10:36 [Bug middle-end/14236] New: dynamically-sized arrays break alloca() aoliva at gcc dot gnu dot org
` (8 preceding siblings ...)
2005-02-14 20:23 ` aoliva at gcc dot gnu dot org
@ 2005-02-14 20:26 ` sds at gnu dot org
9 siblings, 0 replies; 11+ messages in thread
From: sds at gnu dot org @ 2005-02-14 20:26 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From sds at gnu dot org 2005-02-14 17:47 -------
(In reply to comment #9)
> - memory allocated with alloca() is released at the time the function that calls
> alloca() returns
oh - I didn't know that.
I always thought that alloca()ted memory is released by the next "}".
(i.e., identical to dynamic arrays).
Thanks for the clarification.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14236
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2005-02-14 17:47 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-02-21 10:36 [Bug middle-end/14236] New: dynamically-sized arrays break alloca() aoliva at gcc dot gnu dot org
2004-02-21 10:37 ` [Bug middle-end/14236] " aoliva at gcc dot gnu dot org
2004-02-21 10:56 ` jsm at polyomino dot org dot uk
2004-02-22 0:06 ` aoliva at gcc dot gnu dot org
2004-02-23 0:40 ` pinskia at gcc dot gnu dot org
2004-04-06 1:06 ` pinskia at gcc dot gnu dot org
2004-04-22 17:50 ` pinskia at gcc dot gnu dot org
2005-02-10 23:45 ` pinskia at gcc dot gnu dot org
2005-02-10 23:57 ` sds at gnu dot org
2005-02-14 20:23 ` aoliva at gcc dot gnu dot org
2005-02-14 20:26 ` sds at gnu dot org
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).