bug in 3.2.0 nmblookup

Sam Liddicott sam at liddicott.com
Fri Jul 4 08:49:44 GMT 2008


* Alan DeKok wrote, On 04/07/08 09:18:
> Sam Liddicott wrote:
>   
>> Thats sick!
>> sa may be a local variable but it is a pointer. Since when did gcc think
>> that local pointers only point locally?
>>     
>
>   It's more complicated than that.  The issue isn't just local pointers,
> but pointer aliasing.
>
>   
The compiler doesn't "know" the pointers are aliases, so that couldn't
affect the decision to optimize away the last statement.

...
>   How about this artificial example:
>
> void blah(void)
> {
> 	struct foo q;
> 	q.bar = 1
> }
>
>   I think everyone can agree that the assignment is useless, and can
> safely be optimized away.
>   
Yes, but it wasn't dereferencing a pointer either.
The statement can be optimized away because the location is going away;
not the same with a pointer target.

>   With pointer aliasing, you have two pointers to the same section of
> memory.  The C compiler doesn't track assignments across pointers of
> different types, so it can re-order writes, as seen in:
>
> http://archives.postgresql.org/pgsql-hackers/2006-04/msg00981.php
>
>   
But it seems like that wasn't the problem here, although you were doing it.
It wasn't a case (you said) of the statements being re-ordered (and it
wouldn't have mattered) but being removed.

Sam


More information about the samba-technical mailing list