On 04/23/2015 11:34 AM, Manuel López-Ibáñez wrote:
It seems also weird we do not warn directly for '*(int *)0' in the C/C++
FE.

Agreed.

Using decl_with_nonnull_addr_p doesn't make sense for reference variables,
since we're using their pointer value rather than their address.

Is an extra check needed at all (can &reference ever be false)?

No, I don't think we need any extra check here.

The discussion (and perhaps the patch) at
https://gcc.gnu.org/bugzilla/PR65168 may be relevant.

Yes, I thought this sounded familiar...

I think this case requires a slightly different text because the address
may not evaluate to 'true' and also because it is not actually the
address of the reference but the object bounded to the reference.

I agree with the first point, but C++ (unfortunately) uses "address" to refer both to the actual numerical address and the result of the & operator. So I think it's OK to use the word in the latter sense here.

The testcases:

int fii(int *p) {
   int &r=*p;
   return !&r;
}

int fii(int p) {
   int &r=p;
   return !&r;
}

should also generate the same warning in my opinion.

Agreed.

Jason

Reply via email to