digitalmars.D.learn - "Error: Error: conversion 8,"
- jicman (17/17) Mar 18 2005 Has anyone seen this error before? I did a search on DigitalMars.com an...
- J C Calvarese (15/18) Mar 18 2005 I'm not familiar with this error, but I've got some ideas.
- J C Calvarese (7/22) Mar 22 2005 I think I meant "dmd\src\phobos\std\conv.d".
- jicman (3/22) Mar 23 2005 yes. :-)
- AEon (13/22) Mar 20 2005 jicman says...
- Alex Stevenson (23/51) Mar 20 2005 Since arrays are reference types, doesn't this mean that only the
- Paul Bonser (8/80) Apr 20 2005 It's probably good to notice that while both of these work, you can't
Has anyone seen this error before? I did a search on DigitalMars.com and didn't find anything with that error. It does not say a line or anything, but I think it has to do with this: char[] SomeFunction() { char[] str = "blah blah"; return str; } void main() { char[] ch = SomeFunction()[0..5]; } this code compiles and returns the right stuff. But it may be that the real program is too complicated and it's failing. Anyway, just thought I'd ask if someone has seen this before. thanks. jic
Mar 18 2005
jicman wrote:Has anyone seen this error before? I did a search on DigitalMars.com and didn't find anything with that error. It does not say a line or anything, but I think it has to do with this:I'm not familiar with this error, but I've got some ideas. Here's what I did: I searched for "Error: conversion" in Phobos... which was found in ConvError (in dmd\src\phobos\stdconv\conv.d)... which was called by conv_error... which was called by toInt, toUint, toLong, toUlong. So it looks like the problem is in conv.d (std.conv). One of these function is being called incorrectly: toInt, toUint, toLong, toUlong Since I didn't see any of those functions in your sample, I guess the problem part is somewhere else. Hopefully, it'll be easier to find now. -- Justin (a/k/a jcc7) http://jcc_7.tripod.com/d/
Mar 18 2005
J C Calvarese wrote:jicman wrote:I think I meant "dmd\src\phobos\std\conv.d". (Oh, well, I'm guessing jicman figured out his problem regardless of my typographical error.) -- Justin (a/k/a jcc7) http://jcc_7.tripod.com/d/Has anyone seen this error before? I did a search on DigitalMars.com and didn't find anything with that error. It does not say a line or anything, but I think it has to do with this:I'm not familiar with this error, but I've got some ideas. Here's what I did: I searched for "Error: conversion" in Phobos... which was found in ConvError (in dmd\src\phobos\stdconv\conv.d)...
Mar 22 2005
J C Calvarese says...J C Calvarese wrote:yes. :-) I am very forgiving. :-)jicman wrote:I think I meant "dmd\src\phobos\std\conv.d". (Oh, well, I'm guessing jicman figured out his problem regardless of my typographical error.)Has anyone seen this error before? I did a search on DigitalMars.com and didn't find anything with that error. It does not say a line or anything, but I think it has to do with this:I'm not familiar with this error, but I've got some ideas. Here's what I did: I searched for "Error: conversion" in Phobos... which was found in ConvError (in dmd\src\phobos\stdconv\conv.d)...
Mar 23 2005
jicman says... I have not tested this, but several things seem quite fishy to me, and may have to do with you problem.char[] SomeFunction() { char[] str = "blah blah"; return str; }Returning str should not be possible, str is empty/undefinded. Since str is a local variable to SomeFunction(), as soon as you leave that function's scope str should not longer exist?void main() { char[] ch = SomeFunction()[0..5]; }This means you are trying to slice a non-existing string. It also surprises me that you can use the slice "operator" on a function's return value. Just tested your code. As you say compiles with -w and runs as you expected. I am obviously not properly understanding something, about the local str var, or this is indeed illegal code, that just "happens" to work? How did you get that Error message though? AEon
Mar 20 2005
Since arrays are reference types, doesn't this mean that only the pointer/length pair of the array is local (on the stack) and the data it points to is on the heap/in the static data segment? The quick test program: #import std.stdio; #int main( char[][] args ) #char[] foo() prints "foo" as expected. Making str equal to "abfoocd".dup (meaning str points to a heap copy of the variable) also produces the expected output. On Sun, 20 Mar 2005 19:11:12 +0000 (UTC), AEon <AEon_member pathlink.com> wrote:jicman says... I have not tested this, but several things seem quite fishy to me, and may have to do with you problem.-- Using Opera's revolutionary e-mail client: http://www.opera.com/m2/char[] SomeFunction() { char[] str = "blah blah"; return str; }Returning str should not be possible, str is empty/undefinded. Since str is a local variable to SomeFunction(), as soon as you leave that function's scope str should not longer exist?void main() { char[] ch = SomeFunction()[0..5]; }This means you are trying to slice a non-existing string. It also surprises me that you can use the slice "operator" on a function's return value. Just tested your code. As you say compiles with -w and runs as you expected. I am obviously not properly understanding something, about the local str var, or this is indeed illegal code, that just "happens" to work? How did you get that Error message though? AEon
Mar 20 2005
Alex Stevenson wrote:Since arrays are reference types, doesn't this mean that only the pointer/length pair of the array is local (on the stack) and the data it points to is on the heap/in the static data segment? The quick test program: #import std.stdio; #int main( char[][] args ) #char[] foo() prints "foo" as expected. Making str equal to "abfoocd".dup (meaning str points to a heap copy of the variable) also produces the expected output. On Sun, 20 Mar 2005 19:11:12 +0000 (UTC), AEon <AEon_member pathlink.com> wrote:It's probably good to notice that while both of these work, you can't edit the first one (in linux, in windows, you can), only the .dup-ed one. -- -PIB -- "C++ also supports the notion of *friends*: cooperative classes that are permitted to see each other's private parts." - Grady Boochjicman says... I have not tested this, but several things seem quite fishy to me, and may have to do with you problem.char[] SomeFunction() { char[] str = "blah blah"; return str; }Returning str should not be possible, str is empty/undefinded. Since str is a local variable to SomeFunction(), as soon as you leave that function's scope str should not longer exist?void main() { char[] ch = SomeFunction()[0..5]; }This means you are trying to slice a non-existing string. It also surprises me that you can use the slice "operator" on a function's return value. Just tested your code. As you say compiles with -w and runs as you expected. I am obviously not properly understanding something, about the local str var, or this is indeed illegal code, that just "happens" to work? How did you get that Error message though? AEon
Apr 20 2005