[PATCH] D11948: Add some macros to abstract marking of parameters as "not null", and use them in <cstring>

Hal Finkel via cfe-commits cfe-commits at lists.llvm.org
Tue Aug 11 14:08:29 PDT 2015


----- Original Message -----
> From: "Marshall Clow via cfe-commits" <cfe-commits at lists.llvm.org>
> To: "mclow lists" <mclow.lists at gmail.com>, chandlerc at gmail.com, richard at metafoo.co.uk, eric at efcs.ca
> Cc: joerg at NetBSD.org, cfe-commits at lists.llvm.org
> Sent: Tuesday, August 11, 2015 3:30:10 PM
> Subject: Re: [PATCH] D11948: Add some macros to abstract marking of parameters as "not null", and use them in
> <cstring>
> 
> mclow.lists added a comment.
> 
> In http://reviews.llvm.org/D11948#221991, @joerg wrote:
> 
> > No, it doesn't. It tells the compiler that it is free to make such
> > assumptions.
> 
> 
> Again, I disagree. The compiler already knows it is free to make such
> assumptions.
> (LLVM has an entire optimizer pass devoted to `memcpy` and friends)

I agree with Marshall. This ship has already sailed - the standard says what is says, and GCC and other compilers already take advantage of it, and thus portable code already cannot depend on the behavior of passing null pointers. Even non-portable code will be locked to specific compiler/library versions (which is already true with GCC) because, annotations aside, compilers are free to assume the standard semantics regardless. The annotations at least give users some more information on what the compiler is assuming, and so having them is better than not.

 -Hal

> 
> 
> http://reviews.llvm.org/D11948
> 
> 
> 
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
> 

-- 
Hal Finkel
Assistant Computational Scientist
Leadership Computing Facility
Argonne National Laboratory


More information about the cfe-commits mailing list