digitalmars.D.learn - Possible problem with new array
- bearophile (12/12) May 01 2008 The following code:
- boyd (15/15) May 02 2008 I've been trying to work with the D2 xml module. It compiles fine, but ...
- Gide Nwawudu (11/26) May 02 2008 If widget.xml is malformed, it crashes. Probably a bug.
- boyd (17/49) May 02 2008 Except that the check(s) function that is supposed to check this, didn't...
- Gide Nwawudu (6/16) May 02 2008 It doesn't compile on D2.013 either, looks like a bug. The workaround
The following code: void main() { int[1] a = [10]; int i; int[] b = new int[a[i]]; } Generates this error (DMD V.1.028): need size of rightmost array, not type a[i] Is this a DMD bug or an error of mine? Thank you, bear hugs, bearophile
May 01 2008
I've been trying to work with the D2 xml module. It compiles fine, but = when I run it I get an access violation. Am I doing something wrong? module main; import std.stdio; import std.file; import std.xml; int main(){ string s =3D cast(string)std.file.read("widget.xml"); check(s); auto doc =3D new Document(s); writefln(doc); return 0; } Cheers, Boyd
May 02 2008
On Fri, 02 May 2008 09:34:00 +0200, boyd <gaboonviper gmx.net> wrote:I've been trying to work with the D2 xml module. It compiles fine, but when I run it I get an access violation. Am I doing something wrong? module main; import std.stdio; import std.file; import std.xml; int main(){ string s = cast(string)std.file.read("widget.xml"); check(s); auto doc = new Document(s); writefln(doc); return 0; } Cheers, BoydIf widget.xml is malformed, it crashes. Probably a bug. Tested with the following; the first errors, the second version is ok. [widget.xml] <?xml version="1.0"?><widget> [/widget.xml] [widget.xml] <?xml version="1.0"?><widget></widget> [/widget.xml] Gide
May 02 2008
Except that the check(s) function that is supposed to check this, didn't= = give any errors. I found the bug though. Apparently if a closed <node/> is written inside= = another node, an access violation occurs. works: <?xml version=3D"1.0"?><tag/> doesn't work: <?xml version=3D"1.0"?><something><tag/></something> I'll post this on bugzilla. Thanks for trying to help though. Cheers, Boyd ------- On Fri, 02 May 2008 14:38:36 +0200, Gide Nwawudu <gide btinternet.com> = wrote:On Fri, 02 May 2008 09:34:00 +0200, boyd <gaboonviper gmx.net> wrote:tI've been trying to work with the D2 xml module. It compiles fine, bu=when I run it I get an access violation. Am I doing something wrong? module main; import std.stdio; import std.file; import std.xml; int main(){ string s =3D cast(string)std.file.read("widget.xml"); check(s); auto doc =3D new Document(s); writefln(doc); return 0; } Cheers, BoydIf widget.xml is malformed, it crashes. Probably a bug. Tested with the following; the first errors, the second version is ok. [widget.xml] <?xml version=3D"1.0"?><widget> [/widget.xml] [widget.xml] <?xml version=3D"1.0"?><widget></widget> [/widget.xml] Gide
May 02 2008
On Thu, 01 May 2008 20:50:05 -0400, bearophile <bearophileHUGS lycos.com> wrote:The following code: void main() { int[1] a = [10]; int i; int[] b = new int[a[i]]; } Generates this error (DMD V.1.028): need size of rightmost array, not type a[i] Is this a DMD bug or an error of mine?It doesn't compile on D2.013 either, looks like a bug. The workaround is to put a[i] in parenthesis.int[] b = new int[a[i]];int[] b = new int[(a[i])]; Gide
May 02 2008