[cfe-commits] r148374 - in /cfe/trunk: lib/AST/ExprConstant.cpp test/SemaCXX/constexpr-strlen.cpp

Howard Hinnant hhinnant at apple.com
Thu Jan 19 11:56:01 PST 2012


On Jan 19, 2012, at 2:30 PM, Matthieu Monrocq wrote:

> 
> 
> Le 19 janvier 2012 17:52, Jonathan Sauer <jonathan.sauer at gmx.de> a écrit :
> >> Do you know if the same apply (I would guess so) to std::strlen ?
> >>
> >> It seems a pity that such a trivial function could not be constexpr as making it constexpr is actually dead simple. I wonder if it would be worth a Defect Report.
> >>
> > This would seem very reasonable to me...
> 
> As well as a lot (all?) of the math functions in cmath. And clang's built-ins (__builtin_sin etc), too.
> 
> 
> What do you think?
> Jonathan
> 
> I haven't followed the C11 proposal, is the "constexpr" idea addressed there or would it be a specific C++ issue ?
> 
> C++ imports a massive amount of C functions, and keeping their signature as-is will be a hindrance, I don't fancy the idea of recoding them all in pure C++ to allow such optimizations! It seems like at least the `std::` versions could be made `constexpr` when possible. 
> 
> I am putting Howard in copy since this seems something libc++ would be interested in, and perhaps his C++ committee experience could help us here.
> 
> -- Matthieu

I have not come up to speed on constexpr.  However, I do know that if it is the case that no conforming program could detect (or behave differently -- besides performance) if the constexpr is added to a C function, then it should be ok.

Howard





More information about the cfe-commits mailing list