Reproducible expressions
Year: 2024
Type: report
Abstract: To qualify if an array is a VLA or not, the status of the so-called “size” expression is important. If it is an integer constant expression, the array is not a VLA and all its properties are determined at translation time. Otherwise, it is a VLA and the type expression is “evaluated” whenever size information is needed. In particular, type expressions of VM types where the “size” expression has side effects may (or may not) be evaluated each time it is met during execution, and thus the side effects may or may not take place.We think that this “feature” is is actually a bug of the specification and that real world examples where side effects appear in “size” expressions are rare and most often erroneous. They may appear when the “size” expression is a macro invocation or a function call, and when the extent to which side effects appear are not properly mastered.Unfortunately, the following features are often confusedthe syntactic position of an expressionthe point in time during execution when an expression is met,the point in time when an expression is evaluated, in particular if an expression is evaluated attranslation time (e.g integer constant expressions),at link time (e.g address constants), orduring the execution of the program when it is met,and whether or not an evaluation has a side effect.Note that to determine if a type is a VM type or not, in general the distinction between link time and execution is not relevant, so in the following we will not distinguish these two cases. We are left with three possibilities for “size” expressions:it is an integer constant expressionotherwise, it is an expression of integer type but never has side effectsotherwise, it is an expression of integer type that in some executions may have a side effect.The goal of this papers is constrain the definitions of array declarator such that the third case never happens, and so to guarantee that the only form of runtime evaluation that happens when meeting a VLA type expression is an implicit lvalue conversion of the hidden information about the number of elements.
Source: HAL
Author: Gustedt, Jens
Language: English
Subfield: Software
Field: Computer Science
Domain: Physical Sciences
Keywords: C programming language, adverse effects
Open Access status: green
OpenAlex ID: W4404656604
