Handling of wide string literals
Steps to reproduce the issue
Evaluate sizeof(L"AA")
during preprocessing, possibly as part of a _Static_assert
. Take for example the following code snippet:
_Static_assert(sizeof(L"AA") == 12, "Incorrect sizeof behaviour");
int main(void){}
This compiles fine with GCC, but fails preprocessing with frama-c -wp
. With varying string lengths, the assertion succeeds Frama-C preprocessing when replacing 12 with the pointer size, but fails to compile with GCC.
Expected behaviour
The expression evaluates to sizeof(wchar_t) * 3
, typically 12.
Actual behaviour
The expression evaluates to sizeof(wchar_t *)
, typically 4 or 8.
Contextual information
- Frama-C installation mode: Opam
- Frama-C version: 27.1 (Cobalt)
- Plug-in used: WP
- OS name: macOS
- OS version: 14.0
Additional information (optional)
A quick search of the source code yields several special handling of string literals, e.g. the definition of SizeOfStr()
. It appears most to all of the related code is specific to char
string literals with no support for wchar_t
string literals (both as in they do not seem to get special handling, and there is no support in the existing literal code to vary the character size). As I am new to the codebase, please feel free to confirm or correct my observations. Thank you!