[cfe-dev] Semantics of Value Dependent and Integral Constant Expressions

Friedman, Eli via cfe-dev cfe-dev at lists.llvm.org
Fri Nov 17 12:09:37 PST 2017


On 11/16/2017 6:49 PM, Davis, Matthew via cfe-dev wrote:
> In the case of sizeof(T), where T is a template type argument, T is dependent; therefore, sizeof(T) is considered a value dependent constant expression.  Why is sizeof(T) disallowed from being an ICE in checkInitIsICE()?

For all T (excluding VLAs, which aren't part of the standard), sizeof(T) 
is an constant expression, yes.  But in general, it's impossible to tell 
whether a value-dependent expression is a constant expression, so we 
just don't check value-dependent expressions for the sake of 
simplicity.  (Consider, for example, "sizeof(T) > 10 ? 5 : 
printf("asdf");".)

-Eli

-- 
Employee of Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project




More information about the cfe-dev mailing list