This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: [C++] value-dependent expressions and static_cast
- From: Gabriel Dos Reis <gdr at integrable-solutions dot net>
- To: "Giovanni Bajo" <giovannibajo at libero dot it>
- Cc: <gcc at gcc dot gnu dot org>
- Date: 18 Jun 2003 06:59:35 +0200
- Subject: Re: [C++] value-dependent expressions and static_cast
- Organization: Integrable Solutions
- References: <027801c33531$b0e170e0$114e2697@bagio>
"Giovanni Bajo" <giovannibajo@libero.it> writes:
| Hello,
|
| What does exactly "value-dependent" expression mean, as implemented by
| pt.c:value_dependent_expression_p()?
See standard description at 14.6.2.3.
| I can't fully make it out and it does
| not seem very well documented in the comments. My understanding is that it
| means "an expression whose value depends on a template paramter and thus
| cannot be fully simplified before instantiation". Is this correct?
Nearly but not exactly.
| In this case, I think the code to handle *_CAST_EXPR within
| value_dependent_expression_p is incomplete, because it should also verify if
| the operand of the cast expression is value-dependent or not, as in:
| /* These expressions are value-dependent if the type to which the
| - cast occurs is dependent. */
| + cast occurs is dependent or the expression being casted is
| + value-dependent. */
14.6.2.3/3 handles those:
Expressions of the following form are value-dependent if either the
type-id or simple-type-specifier is dependent or the expression or
cast-expression is value-dependent:
| if ((TREE_CODE (expression) == DYNAMIC_CAST_EXPR
| || TREE_CODE (expression) == STATIC_CAST_EXPR
| || TREE_CODE (expression) == CONST_CAST_EXPR
| || TREE_CODE (expression) == REINTERPRET_CAST_EXPR
| || TREE_CODE (expression) == CAST_EXPR)
| - && dependent_type_p (TREE_TYPE (expression)))
| + && (dependent_type_p (TREE_TYPE (expression))
| + || value_dependent_expression_p (TREE_OPERAND (expression, 0))))
| return true;
|
| Does this make any sense?
Yes.
| Also, given a template parameter T and auto T t[2], is &t[1] a
| value-dependent expression?
No.
-- Gaby