Internal Error

Neil Vice psgdg at swiftdsl.com.au
Wed Apr 2 07:43:05 PDT 2008


"Steven Schveighoffer" <schveiguy at yahoo.com> wrote in message 
news:ft04i9$5in$1 at digitalmars.com...
> "Neil Vice" wrote in message
>> I've encountered the following error in DMD 2.012:
>>
>>    Internal error: ..\ztc\cod1.c 1662
>>
>> I would submit a bug report except that I can't seem to determine a 
>> simple case that produces the bug, so I guess I'm looking for some 
>> assistance in narrowing down the problem.
>>
>> I have two structs, one representing a time-stamp and another 
>> representing a time-period. They both implement opSub. Nested within a 
>> method in a class within a class in a seperate package I have some code 
>> along the lines of:
>>
>>    auto result = a - (b - c);
>>
>> where a is a TimePeriod and b & c are TimeStamps.
>>
>> If I replace this line with:
>>
>>    auto _result = b - c;
>>    auto result = a - _result;
>>
>> the Internal error goes away.
>>
>> I have attempted to construct a simple case with two similar structs with 
>> opSub methods and a main() containing the problem expression, however I 
>> cannot reproduce the error.
>>
>> Any suggestions on where to go from here?
>
> Try to reproduce the error with a simple main function that does just the 
> lines above.
>
> If this still fails, then try removing pieces of your classes, making sure 
> the error remains.  When you narrow that down, you might be able to see 
> clearer what the minimal case is.
>
> If this doesn't fail, then try moving around where you are making the auto 
> result = a - (b - c) call, trying to simplify that code.
>
> Good luck.
>
> -Steve

Well I had another crack at it and have come up with a simpler case.

The error only occurs when you attempt an operation (duplicated only for + 
and - so far) on operands for which that operation has not been defined. 
Furthermore it appears that one of the operands must be a const variable. 
I've also only encountered the error when the other operand was the result 
of another expression i.e. not a simple variable.

What's interesting also is the fact that replacing "auto result = a - (b - 
c);" with "auto tmp = b - c; auto result = a - tmp;" neither causes the 
internal error nor causes a compile error due to the fact that the operation 
"a - tmp" is undefined as far as I can tell.

I wonder what the compiler actually generates there...

http://d.puremagic.com/issues/show_bug.cgi?id=1969






More information about the Digitalmars-d mailing list