Repository navigation
GNU C typeof omits side effects of a variably modified operand #295
71iq
started this conversation in
Issue Triage - Compilation
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Version
Compiler: 7.0, commit
43e10b90fc83ed2a436fb79b241be8dbf3dc6846Platform: Linux x86_64 (LP64)
Reference/compiler for generated C: GCC 13.3.0
Preset:
linux-gcc-debug, withEDG_CPFE_USE_ASAN=OFFRelevant configuration:
Code to reproduce
Compiler options:
Behavior
The
typeofoperand has variably modified type: a pointer to a variable-length array. GNU C evaluates such an operand for its side effects, so++kshould execute and the assertion should pass.The reference program compiled with GCC exits with status 0. The translated program aborts:
The generated C contains no increment of
k; its value remains 1.This concerns variably modified operands. An ordinary
typeof(++k)whose type isintshould remain unevaluated. The positive initial bound and use ofsizeof(p)avoid a zero-sized VLA or reading an uninitialized pointer.Reference: GCC typeof documentation.
The attachment contains the full
--dump_configurationoutput and self-contained reproduction inputs.Source, generated C, results, and full configuration
Reporting acknowledgements
I acknowledge that:
LICENSE.txtfile in my.zipor.tar.gzupload. If I included aLICENSE.txtfile, any tests created using the reproducing source code will be governed by the terms of the license I provided instead.All reactions