digitalmars.D.announce - segfault when printing 2 dimentional array
- Ameer Armaly (12/12) Jul 22 2005 Hi all.
- Derek Parnell (16/23) Jul 23 2005 The split() function returns a set of slices into its parameter. If you ...
-
Stewart Gordon
(12/25)
Jul 25 2005
- Ben Hinkle (11/18) Jul 23 2005 I think you wanted to post this to D.bugs and not D.announce.
- Dave (5/23) Jul 23 2005 With DMD v0.128, this code doesn't segfault on either Windows or Linux d...
Hi all. The following code makes the compiler segfault: import std.stdio, std.string; void main() { writefln(split("A b")); } -- --- Life is either tragedy or comedy. Usually it's your choice. You can whine or you can laugh. --Animorphs
Jul 22 2005
On Fri, 22 Jul 2005 17:52:14 -0400, Ameer Armaly wrote:Hi all. The following code makes the compiler segfault: import std.stdio, std.string; void main() { writefln(split("A b")); }The split() function returns a set of slices into its parameter. If you are running on Linux, the string literal is in protected RAM so writes to it will fail. When I run your test on Windows, I just get a bad format code message. Here is my version of your test to make it work ... import std.stdio, std.string; void main() { foreach(char[] s; split("A b".dup)) writefln(s); } -- Derek Parnell Melbourne, Australia 23/07/2005 8:59:00 PM
Jul 23 2005
Derek Parnell wrote:On Fri, 22 Jul 2005 17:52:14 -0400, Ameer Armaly wrote:<snip> Why would this code cause a write to the string literal? Stewart. -- -----BEGIN GEEK CODE BLOCK----- Version: 3.1 GCS/M d- s:- a->--- UB P+ L E W++ N+++ o K- w++ O? M V? PS- PE- Y? PGP- t- 5? X? R b DI? D G e++>++++ h-- r-- !y ------END GEEK CODE BLOCK------ My e-mail is valid but not my primary mailbox. Please keep replies on the 'group where everyone may benefit.Hi all. The following code makes the compiler segfault: import std.stdio, std.string; void main() { writefln(split("A b")); }The split() function returns a set of slices into its parameter. If you are running on Linux, the string literal is in protected RAM so writes to it will fail.
Jul 25 2005
"Ameer Armaly" <ameer_armaly hotmail.com> wrote in message news:dbrprs$1pb6$1 digitaldaemon.com...Hi all. The following code makes the compiler segfault: import std.stdio, std.string; void main() { writefln(split("A b")); }I think you wanted to post this to D.bugs and not D.announce. On Windows the compiler didn't seg-v (since you say seg-v I assume you're on Linux, though) but it does give a FormatError when you run the program. That's because general dynamic arrays are not handled by std.format.doFormat. I've fixed up doFormat to write the string [s_1,s_2,...,s_N] where s_k is the result of calling doFormat recursively on the kth element of the array. Right now I have it working for dynamic arrays. I'll try to get static and associative arrays going and send the result to Walter.
Jul 23 2005
In article <dbteao$6oa$1 digitaldaemon.com>, Ben Hinkle says..."Ameer Armaly" <ameer_armaly hotmail.com> wrote in message news:dbrprs$1pb6$1 digitaldaemon.com...With DMD v0.128, this code doesn't segfault on either Windows or Linux during compilation and 'Error: std.format formatArg' is the result when it is run on either. - DaveHi all. The following code makes the compiler segfault: import std.stdio, std.string; void main() { writefln(split("A b")); }I think you wanted to post this to D.bugs and not D.announce. On Windows the compiler didn't seg-v (since you say seg-v I assume you're on Linux, though) but it does give a FormatError when you run the program. That's because general dynamic arrays are not handled by std.format.doFormat. I've fixed up doFormat to write the string [s_1,s_2,...,s_N] where s_k is the result of calling doFormat recursively on the kth element of the array. Right now I have it working for dynamic arrays. I'll try to get static and associative arrays going and send the result to Walter.
Jul 23 2005