D - [dmd crash] on global scope operator
- Manfred Nowak (4/4) Mar 12 2004 dmd 0.81 on WIN98SE crashes on:
- Andrew Edwards (5/9) Mar 13 2004 Not sure what the . in .arr[] represents but your code compiles correctl...
- J C Calvarese (8/22) Mar 13 2004 I think it's supposed to be a Module Scope Operator (see
- Manfred Nowak (11/12) Mar 13 2004 I know that. As always when reducing something to the minimum, the
- Andrew Edwards (17/30) Mar 14 2004 Your intentions is much clearer. As for the GPF generated by your code,
- Manfred Nowak (32/33) Mar 14 2004 [...]
- Andrew Edwards (42/48) Mar 14 2004 I see your point. But this is one case, IMHO, where automatic
- Manfred Nowak (6/12) Mar 15 2004 Agreed. It is probably very seldom, that there is the wish to initialize...
dmd 0.81 on WIN98SE crashes on: const char[1] arr; char[] arr2=.arr[]; So long.
Mar 12 2004
On Sat, 13 Mar 2004 07:42:05 +0100, Manfred Nowak <svv1999 hotmail.com> wrote:dmd 0.81 on WIN98SE crashes on: const char[1] arr; char[] arr2=.arr[]; So long.Not sure what the . in .arr[] represents but your code compiles correctly without it. Andrew
Mar 13 2004
Andrew Edwards wrote:On Sat, 13 Mar 2004 07:42:05 +0100, Manfred Nowak <svv1999 hotmail.com> wrote:I think it's supposed to be a Module Scope Operator (see http://www.digitalmars.com/d/module.html). It looks like valid code to me, but whether it's valid or not, DMD shouldn't GPF when it's compiled. So I'd call it a bug.dmd 0.81 on WIN98SE crashes on: const char[1] arr; char[] arr2=.arr[]; So long.Not sure what the . in .arr[] represents but your code compiles correctly without it.Andrew-- Justin http://jcc_7.tripod.com/d/
Mar 13 2004
Andrew Edwards wrote: [...]your code compiles correctly without it.I know that. As always when reducing something to the minimum, the stimulating context is lost. I deleted three unnecessary lines from that test where it made more sense: const char[1] arr; void main(){ const char[2] arr; char[] arr2=.arr[]; } So long.
Mar 13 2004
On Sun, 14 Mar 2004 00:47:36 +0100, Manfred Nowak <svv1999 hotmail.com> wrote:Andrew Edwards wrote: [...]Your intentions is much clearer. As for the GPF generated by your code, well, its a bug that needs to be addressed. However, why would you declare a costant and not initialize it. The very nature of constant variables suggests and often dictates that they must be initialized upon declaration (defined vs declared). That being the case, const char[1] arr = '1'; // defined: not just declared void main(){ const char[2] arr; char[] arr2=.arr[]; } yields a more desireable result. Of course the compiler should identify the source of the problem instead of simply GPFing. Andrew -- Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/your code compiles correctly without it.I know that. As always when reducing something to the minimum, the stimulating context is lost. I deleted three unnecessary lines from that test where it made more sense: const char[1] arr; void main(){ const char[2] arr; char[] arr2=.arr[]; } So long.
Mar 14 2004
Andrew Edwards wrote: [...]often dictates that they must be initialized[...] Remember that D has automatic initialization. Therefore the crashes here are due to the gobal/module scope operator. This does not crash: const char[1] arr; void main(){ char[] arr2=arr[]; printf("'%c'\n", arr[0]); } but with global/module scope operator it crashes: const char[1] arr; void main(){ char[] arr2=arr[]; printf("'%c'\n", .arr[0]); } This does not crash const char[1] arr; void main(){ const char[1] arr; char[] arr2=arr[]; printf("'%c'\n", arr[0]); } but with global/module scope operator it crashes: const char[1] arr; void main(){ const char[1] arr; char[] arr2=arr[]; printf("'%c'\n", .arr[0]); } So long!
Mar 14 2004
On Sun, 14 Mar 2004 17:19:04 +0100, Manfred Nowak <svv1999 hotmail.com> wrote:Andrew Edwards wrote: [...]I see your point. But this is one case, IMHO, where automatic initialization should not be allowed. A constant is just that "constant". The compiler cannot possibly assume what the author intended for it to represent. If you are going to use a constant, then I'd think it must be explicitly initialized, otherwise you should use a regular variable. This works fine: char[1] arr; // not a constant void main() { const char[2] arr; char[] arr2 = .arr[]; printf(arr2); } And so does this: const char[1] arr = '1'; // initialized constant void main() { const char[2] arr; char[] arr2 = .arr[]; printf(arr2); } So while I don't dispute that the global/module scope operator contributes to the problem, I do know that the problem is compounded by the fact that it is constant. Additionally, because constants are intended to represent non-changing values, they should be explicitly initialized at declaration. Given you initial program: const char[1] arr; void main() { const char[2] arr; char[] arr2 = .arr[]; printf(arr2); } The compiler should respond as follows: crash.d(1): uninitialized constant crash.d(4): uninitialized constant problem solved. Andrew -- Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/often dictates that they must be initialized[...] Remember that D has automatic initialization. Therefore the crashes here are due to the gobal/module scope operator.
Mar 14 2004
Andrew Edwards wrote: [...]The compiler should respond as follows: crash.d(1): uninitialized constant crash.d(4): uninitialized constant problem solved.Agreed. It is probably very seldom, that there is the wish to initialize a constant to the default initilizer for variables. In this rare cases the constant should be initialized explicitely. So long!
Mar 15 2004