Constant expressions can be evaluated at compile time.
Many languages require certain initializers to be constant expressions. For example:
- Array bounds
- Selectors in case statements
- Bit-field length specification
- Enumeration initializers
- Non-type template arguments
A greatly restricted set of operands are allowed in constant expressions. Generally, variables are not allowed. For example, C++ allows:
- Literals
- Enumeration constants
- Values declared as const that are initialized with constant expressions
- sizeof expressions
Questions with this tag usually need help with error messages that indicate lines that require constant expressions.