digitalmars.D.bugs - DMD 0.101: Internal error on array concatenation
- Kramer <Kramer_member pathlink.com> Sep 02 2004
- Stewart Gordon <smjg_1998 yahoo.com> Sep 02 2004
- Kramer <Kramer_member pathlink.com> Sep 02 2004
- "Bent Rasmussen" <exo bent-rasmussen.info> Sep 02 2004
- Kramer <Kramer_member pathlink.com> Sep 02 2004
- Regan Heath <regan netwin.co.nz> Sep 02 2004
I'm not sure if this is a bug or even a legal assignment, but the following
causes an internal error:
import std.file;
void main()
{
char[] curdir;
curdir[0..(getcwd().length-1)] ~= getcwd(); // not sure if this is allowed?
}
Compiling with v0.101 on Windows 2000 with flags -inline -O gives:
Internal error: ..\ztc\cod2.c 4207
I just started using D and am a bit rusty with the old c/c++ skills, let alone
knowing how to do things proper in D, but I'm quite excited to learn... :) I
have been following the NG for a while now and let me say, Walter, fantastic
language! I've learned so much (just about programming and language design in
general) from everyone who posts; I was quite happy just reading, but I've
decided to join the fray. :P
Looking forward to sharpening my D skills and letting some others get a bit
rustier! (not by avoidance of course, just ramping up the D usage) :)
-Kramer
Sep 02 2004
Kramer wrote:I'm not sure if this is a bug or even a legal assignment, but the following causes an internal error:
Every internal error is a bug. Or, at least, every internal error that's reproducible. <snip>curdir[0..(getcwd().length-1)] ~= getcwd(); // not sure if this is allowed?
What were you expecting it to do? Stewart. -- My e-mail is valid but not my primary mailbox. Please keep replies on the 'group where everyone may benefit.
Sep 02 2004
In article <ch6prk$738$1 digitaldaemon.com>, Stewart Gordon says...<snip>curdir[0..(getcwd().length-1)] ~= getcwd(); // not sure if this is allowed?
What were you expecting it to do?
It seems that getcwd() has a an extra character in the string in returns. I can't tell what it is, but I was trying to remove it. As for the assignment, I didn't know if I needed to size the array first or if I could attempt the above, so I just went for it. Debug question: How would I find out what that character is using a printf type debug technique. (I've never used gdb or similar debuggers in windows/unix before). Thanks for the help! -KramerStewart. -- My e-mail is valid but not my primary mailbox. Please keep replies on the 'group where everyone may benefit.
Sep 02 2004
void main() { char[] curdir; curdir[0..(getcwd().length-1)] ~= getcwd(); // not sure if this is allowed? }
This isn't quite on-topic but when I last tried std.file.getcwd it returned a string with a superfluous space at the end. I guess this is why you're trying to create a sliced string. I suggest this getcwd[0 .. length - 1]
Sep 02 2004
In article <ch6qch$77n$1 digitaldaemon.com>, Bent Rasmussen says...void main() { char[] curdir; curdir[0..(getcwd().length-1)] ~= getcwd(); // not sure if this is allowed? }
This isn't quite on-topic but when I last tried std.file.getcwd it returned a string with a superfluous space at the end. I guess this is why you're trying to create a sliced string. I suggest this getcwd[0 .. length - 1]
Yup, that's spot on what I was attempting. Thanks for the tip. -Kramer
Sep 02 2004
On Thu, 2 Sep 2004 16:35:49 +0000 (UTC), Kramer <Kramer_member pathlink.com> wrote:In article <ch6qch$77n$1 digitaldaemon.com>, Bent Rasmussen says...void main() { char[] curdir; curdir[0..(getcwd().length-1)] ~= getcwd(); // not sure if this is allowed? }
This isn't quite on-topic but when I last tried std.file.getcwd it returned a string with a superfluous space at the end. I guess this is why you're trying to create a sliced string. I suggest this getcwd[0 .. length - 1]
Yup, that's spot on what I was attempting. Thanks for the tip.
So the corrected code is simply: char[] curdir; curdir ~= getcwd()[0 .. length -1]; or: char[] curdir; curdir = getcwd()[0 .. length -1]; or: char[] curdir; curdir = getcwd(); curdir.length = curdir.length - 1; Regan -- Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/
Sep 02 2004









Kramer <Kramer_member pathlink.com> 