Thread overview
[dmd-internals] A major root-cause bug
Nov 13, 2010
Don Clugston
Nov 13, 2010
Don Clugston
Nov 14, 2010
Walter Bright
Nov 13, 2010
Walter Bright
November 13, 2010
While tracking down an ICE bug, I found this important issue.

5195 Forward references ignore const

Most of the front-end uses the 'type' member of a variable to check,
and assumes that if it's non-null,
it hasn't been forward referenced.
The problem is, if x is declared as  'const int *x' or  'const { int
*x; }' , it has a non-null type member, but it doesn't have the const
yet!
This bogus type is a root of all kinds of evil. It manifests in a
variety of weird ways.
I think that several previously fixed bugs, were just special cases of this one.

Unfortunately fixing this isn't just a one-liner. It requires a minor
structural change, and I'm not sure which approach is the best way of
fixing it.
Essentially, all the qualifiers need to be resolved before any other
semantic analysis takes place.
Walter, can you comment?
November 13, 2010
To clarify -- this bug is not urgent, but it's one that I think we need to be aware of, because it can have such a wide and unexpected influence.

On 13 November 2010 05:16, Don Clugston <dclugston at googlemail.com> wrote:
> While tracking down an ICE bug, I found this important issue.
>
> 5195 Forward references ignore const
>
> Most of the front-end uses the 'type' member of a variable to check,
> and assumes that if it's non-null,
> it hasn't been forward referenced.
> The problem is, if x is declared as ?'const int *x' or ?'const { int
> *x; }' , it has a non-null type member, but it doesn't have the const
> yet!
> This bogus type is a root of all kinds of evil. It manifests in a
> variety of weird ways.
> I think that several previously fixed bugs, were just special cases of this one.
>
> Unfortunately fixing this isn't just a one-liner. It requires a minor
> structural change, and I'm not sure which approach is the best way of
> fixing it.
> Essentially, all the qualifiers need to be resolved before any other
> semantic analysis takes place.
> Walter, can you comment?
>
November 13, 2010
I'll look at it, but we're having a family thing this weekend.

Don Clugston wrote:
> While tracking down an ICE bug, I found this important issue.
>
> 5195 Forward references ignore const
>
> Most of the front-end uses the 'type' member of a variable to check,
> and assumes that if it's non-null,
> it hasn't been forward referenced.
> The problem is, if x is declared as  'const int *x' or  'const { int
> *x; }' , it has a non-null type member, but it doesn't have the const
> yet!
> This bogus type is a root of all kinds of evil. It manifests in a
> variety of weird ways.
> I think that several previously fixed bugs, were just special cases of this one.
>
> Unfortunately fixing this isn't just a one-liner. It requires a minor
> structural change, and I'm not sure which approach is the best way of
> fixing it.
> Essentially, all the qualifiers need to be resolved before any other
> semantic analysis takes place.
> Walter, can you comment?
> _______________________________________________
> dmd-internals mailing list
> dmd-internals at puremagic.com
> http://lists.puremagic.com/mailman/listinfo/dmd-internals
>
>
> 
November 14, 2010
I actually think it is urgent. I've found and fixed the particular problem. But you're right, there is a more general problem. I want to switch out the way it does semantic analysis from the way it's done now, eagerly, to a lazy method. By lazy I mean it does the semantic analysis of symbols as required. This should eliminate all the forward reference issues.

Don Clugston wrote:
> To clarify -- this bug is not urgent, but it's one that I think we need to be aware of, because it can have such a wide and unexpected influence.
>
> On 13 November 2010 05:16, Don Clugston <dclugston at googlemail.com> wrote:
> 
>> While tracking down an ICE bug, I found this important issue.
>>
>> 5195 Forward references ignore const
>>
>> Most of the front-end uses the 'type' member of a variable to check,
>> and assumes that if it's non-null,
>> it hasn't been forward referenced.
>> The problem is, if x is declared as  'const int *x' or  'const { int
>> *x; }' , it has a non-null type member, but it doesn't have the const
>> yet!
>> This bogus type is a root of all kinds of evil. It manifests in a
>> variety of weird ways.
>> I think that several previously fixed bugs, were just special cases of this one.
>>
>> Unfortunately fixing this isn't just a one-liner. It requires a minor
>> structural change, and I'm not sure which approach is the best way of
>> fixing it.
>> Essentially, all the qualifiers need to be resolved before any other
>> semantic analysis takes place.
>> Walter, can you comment?
>>
>> 
> _______________________________________________
> dmd-internals mailing list
> dmd-internals at puremagic.com
> http://lists.puremagic.com/mailman/listinfo/dmd-internals
>
>
>