Re: segfaults

2010-02-22 Thread Bernard Helyer
On 23/02/10 15:14, Ellery Newcomer wrote: Is there any decent way to figure out where segfaults are coming from? e.g. 200k lines of bad code converted from java I tried gdb, and it didn't seem to work too well. Die: DW_TAG_type_unit (abbrev 3, offset 0x6d) parent at offset: 0xb has children: F

Re: When is array-to-array cast legal, and what does actually happen?

2010-02-22 Thread Ali Çehreli
Daniel Keep wrote: >> ... >> >> I see that neither the constructor nor the postblit is called. >> Apparently the bit representation is used. This has the risk of >> violating struct invariants. >> >> Is it legal? >> >> Thank you, >> Ali > > cast is to value conversions what a tactical nuclear stri

Bizarre find() error [D2]

2010-02-22 Thread Jonathan M Davis
Okay, I'm trying to find out if a particular string is in an array of strings. The best function that I can find for that appears to be find(), since there's no contains() or anything like that and in only works for associative arrays. So, my code is something similar to this: string[] list;

Re: segfaults

2010-02-22 Thread Ellery Newcomer
On 02/22/2010 08:41 PM, Jesse Phillips wrote: Ellery Newcomer wrote: Is there any decent way to figure out where segfaults are coming from? e.g. 200k lines of bad code converted from java I tried gdb, and it didn't seem to work too well. Die: DW_TAG_type_unit (abbrev 3, offset 0x6d) pare

Re: segfaults

2010-02-22 Thread Jesse Phillips
Ellery Newcomer wrote: > Is there any decent way to figure out where segfaults are coming from? > > e.g. 200k lines of bad code converted from java > > I tried gdb, and it didn't seem to work too well. > > Die: DW_TAG_type_unit (abbrev 3, offset 0x6d) >parent at offset: 0xb >has children:

segfaults

2010-02-22 Thread Ellery Newcomer
Is there any decent way to figure out where segfaults are coming from? e.g. 200k lines of bad code converted from java I tried gdb, and it didn't seem to work too well. Die: DW_TAG_type_unit (abbrev 3, offset 0x6d) parent at offset: 0xb has children: FALSE attributes: DW_AT_byte_size

Re: When is array-to-array cast legal, and what does actually happen?

2010-02-22 Thread Daniel Keep
> ... > > I see that neither the constructor nor the postblit is called. > Apparently the bit representation is used. This has the risk of > violating struct invariants. > > Is it legal? > > Thank you, > Ali cast is to value conversions what a tactical nuclear strike is to peaceful negotiations

Re: Commmandline arguments and UTF8 error

2010-02-22 Thread Daniel Keep
Jacob Carlborg wrote: > On 2010-02-22 15.39, Nils Hensel wrote: >> Daniel Keep schrieb: >>> If you look at the real main function in src\phobos\internal\dmain2.d, >>> you'll see this somewhere around line 109 (I'm using 1.051, but it's >>> unlikely to be much different in an earlier version): >>>

When is array-to-array cast legal, and what does actually happen?

2010-02-22 Thread Ali Çehreli
Is the following cast legal with dmd 2.040? struct MyChar { dchar d; this(dchar param) in { assert(false); // not called } body { d = param; assert(d != param); // not called } this(this) in { assert(false); // not

Re: Running external program from a D program [D2]

2010-02-22 Thread Jesse Phillips
Jonathan M Davis Wrote: > Jesse Phillips wrote: > > Please note that I do not know how any of this will related to practices > > on Windows. And sadly this is not D specific and actually C stuff. > > > > 1. http://www.opengroup.org/onlinepubs/007908799/xsh/exec.html > > 2. http://www.yolinux.com/

Re: Commmandline arguments and UTF8 error

2010-02-22 Thread Jacob Carlborg
On 2010-02-22 15.39, Nils Hensel wrote: Daniel Keep schrieb: If you look at the real main function in src\phobos\internal\dmain2.d, you'll see this somewhere around line 109 (I'm using 1.051, but it's unlikely to be much different in an earlier version): for (size_t i = 0; i< argc; i++) {

Re: Running external program from a D program [D2]

2010-02-22 Thread Jérôme M. Berger
Jonathan M Davis wrote: > Jesse Phillips wrote: >> As you may have noticed by the comments to on bug 3158. exec()[1] calls >> replace your process, this means it will not continue your program. To >> get arround this you find that people will first fork()[2] and exec on >> the child process. > > A

Re: Commmandline arguments and UTF8 error

2010-02-22 Thread Don
Nils Hensel wrote: Lars T. Kyllingstad schrieb: I just realised that D2 also does what Daniel says Tango does. I guess this is because D2's runtime, druntime, is based on Tango's runtime. So most likely you don't need to use std.encoding after all. Really? So all I'd need to do would be to s

Re: Commmandline arguments and UTF8 error

2010-02-22 Thread Nils Hensel
Lars T. Kyllingstad schrieb: > I just realised that D2 also does what Daniel says Tango does. I guess > this is because D2's runtime, druntime, is based on Tango's runtime. So > most likely you don't need to use std.encoding after all. Really? So all I'd need to do would be to switch to D2? I'd

Re: immutable string literal?

2010-02-22 Thread Steven Schveighoffer
On Mon, 22 Feb 2010 11:24:36 -0500, strtr wrote: Steven Schveighoffer Wrote: But still, what does it matter? Just don't use D1 if you want a compiler error, or don't try and trick the system into modifying ROM! There are plenty of projects using D1 that just don't do this, and they are

Re: immutable string literal?

2010-02-22 Thread strtr
Steven Schveighoffer Wrote: > > But still, what does it matter? Just don't use D1 if you want a compiler > error, or don't try and trick the system into modifying ROM! There are > plenty of projects using D1 that just don't do this, and they are fine. > Implementing features to help peop

Re: immutable string literal?

2010-02-22 Thread Steven Schveighoffer
On Mon, 22 Feb 2010 10:19:52 -0500, grauzone wrote: Steven Schveighoffer wrote: On Mon, 22 Feb 2010 09:27:57 -0500, strtr wrote: Thanks, I understand. But, how about a runtime error? Isn't a literal placed in easy to identify should-only-read memory? A segfault is a runtime error. The prob

Re: immutable string literal?

2010-02-22 Thread strtr
grauzone Wrote: > > Windows can protect memory as read-only too. Why dmd doesn't do that is > a mystery. Even if .exe doesn't support read-only data segments, the > runtime could have done so in early start-up code. > If that is the case, then I'd suggest a(n enhancement?) bug-report :)

Re: immutable string literal?

2010-02-22 Thread grauzone
Steven Schveighoffer wrote: On Mon, 22 Feb 2010 09:27:57 -0500, strtr wrote: Thanks, I understand. But, how about a runtime error? Isn't a literal placed in easy to identify should-only-read memory? A segfault is a runtime error. The problem with Windows is it doesn't throw an error on writ

Re: Commmandline arguments and UTF8 error

2010-02-22 Thread Lars T. Kyllingstad
Lars T. Kyllingstad wrote: Nils Hensel wrote: Daniel Keep schrieb: If you look at the real main function in src\phobos\internal\dmain2.d, you'll see this somewhere around line 109 (I'm using 1.051, but it's unlikely to be much different in an earlier version): for (size_t i = 0; i < argc; i++

Re: Commmandline arguments and UTF8 error

2010-02-22 Thread Lars T. Kyllingstad
Nils Hensel wrote: Daniel Keep schrieb: If you look at the real main function in src\phobos\internal\dmain2.d, you'll see this somewhere around line 109 (I'm using 1.051, but it's unlikely to be much different in an earlier version): for (size_t i = 0; i < argc; i++) { auto len = strlen(ar

Re: immutable string literal?

2010-02-22 Thread Steven Schveighoffer
On Mon, 22 Feb 2010 09:27:57 -0500, strtr wrote: Thanks, I understand. But, how about a runtime error? Isn't a literal placed in easy to identify should-only-read memory? A segfault is a runtime error. The problem with Windows is it doesn't throw an error on writes to its data segment (unli

Re: Commmandline arguments and UTF8 error

2010-02-22 Thread Nils Hensel
Daniel Keep schrieb: > If you look at the real main function in src\phobos\internal\dmain2.d, > you'll see this somewhere around line 109 (I'm using 1.051, but it's > unlikely to be much different in an earlier version): > >> for (size_t i = 0; i < argc; i++) >> { >> auto len = strlen(argv[i])

Re: immutable string literal?

2010-02-22 Thread strtr
Steven Schveighoffer Wrote: > On Mon, 22 Feb 2010 08:32:20 -0500, strtr wrote: > > > Daniel Keep Wrote: > > > >> > >> strtr wrote: > >> > On winXP (D1) I can compile/run this code without a problem. > >> > Not even a warning. > >> > > >> > void main() { > >> > char[] s= "immutable literal?"; >

Re: immutable string literal?

2010-02-22 Thread Steven Schveighoffer
On Mon, 22 Feb 2010 08:32:20 -0500, strtr wrote: Daniel Keep Wrote: strtr wrote: > On winXP (D1) I can compile/run this code without a problem. > Not even a warning. > > void main() { > char[] s= "immutable literal?"; > s[$-1] = '!'; > writefln(s); > } > Codepad runs into a segmentatio

Re: immutable string literal?

2010-02-22 Thread strtr
Daniel Keep Wrote: > > strtr wrote: > > On winXP (D1) I can compile/run this code without a problem. > > Not even a warning. > > > > void main() { > > char[] s= "immutable literal?"; > > s[$-1] = '!'; > > writefln(s); > > } > > Codepad runs into a segmentation fault. > > http://codepad.or

Re: Running external program from a D program [D2]

2010-02-22 Thread Lars T. Kyllingstad
Jonathan M Davis wrote: Okay, I'm looking to be able to run an external program from within my D program. The library functions for this appear to be in std.process. You have system() and various versions of execv(). system() makes a call in shell. execv() executes the program without a shell.