digitalmars.D.bugs - [Issue 5683] New: Calling .clear on a fresh associative array causes subsequent segfault
- d-bugmail puremagic.com (28/28) Mar 02 2011 http://d.puremagic.com/issues/show_bug.cgi?id=5683
- d-bugmail puremagic.com (19/19) Apr 04 2011 http://d.puremagic.com/issues/show_bug.cgi?id=5683
- d-bugmail puremagic.com (10/10) Jul 19 2011 http://d.puremagic.com/issues/show_bug.cgi?id=5683
- d-bugmail puremagic.com (19/19) Jul 19 2011 http://d.puremagic.com/issues/show_bug.cgi?id=5683
- d-bugmail puremagic.com (11/11) Aug 04 2011 http://d.puremagic.com/issues/show_bug.cgi?id=5683
http://d.puremagic.com/issues/show_bug.cgi?id=5683
Summary: Calling .clear on a fresh associative array causes
subsequent segfault
Product: D
Version: D2
Platform: x86
OS/Version: Linux
Status: NEW
Severity: major
Priority: P2
Component: DMD
AssignedTo: nobody puremagic.com
ReportedBy: Marco.Leise gmx.de
In DMD 2.051 and 2.052 the following code doesn't run:
void main() {
int[char] test;
test.clear; // <- this provokes the bug
test['x'] = 42;
}
This happens independently of the key type (int, char, struct). It seems like
associative arrays are not in the 'clear' state when they are created.
A typical use case is a field of a class that gets filled with values by a
method that needs to clear out old content if any. I considered this a major
bug, because it happens with a core feature.
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Mar 02 2011
http://d.puremagic.com/issues/show_bug.cgi?id=5683
Iain Buclaw <ibuclaw ubuntu.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |ibuclaw ubuntu.com
This is a horrible bug with .init, and nothing to do with .clear.
Same code but without the external call:
void main() {
int[char] test;
test = typeof(test).init;
test['x'] = 42;
}
What seems to be happening is that the address of the constructor is being
assigned (ie: test = &test_init) when it should *really* be a direct
assignment.
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Apr 04 2011
http://d.puremagic.com/issues/show_bug.cgi?id=5683
dawg dawgfoto.de changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |ratchet.freak gmail.com
*** Issue 5816 has been marked as a duplicate of this issue. ***
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jul 19 2011
http://d.puremagic.com/issues/show_bug.cgi?id=5683
dawg dawgfoto.de changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |dawg dawgfoto.de
A quickfix if urgently needed by anybody is to add a static init method to the
template AA structure.
struct AssociativeArray(Key, Value)
{
static Value[Key] init() property
{
void* p;
return *cast(Value[Key]*)(&p);
}
}
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jul 19 2011
http://d.puremagic.com/issues/show_bug.cgi?id=5683
dawg dawgfoto.de changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution| |DUPLICATE
*** This issue has been marked as a duplicate of issue 6433 ***
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Aug 04 2011









d-bugmail puremagic.com 