Hello!
We have noticed that technical trick with CONST_OPTION macro in options.h can give rise to faulty results.
Considering the example from main.c:
... /* Included from options.h */ extern const /* CONST_OPTION */ optionValues Option; ... static void makeTags (cookedArgs *args) { ... <read Option.recurse> ... } extern int main (int __unused__ argc, char **argv) { ... /* Modification of Option.recurse inside parseOptions */ parseOptions (args); ... makeTags (args); ... }
A compiler can perform an inline expansion of the function 'makeTags' into the function 'main' with the following code:
... /* Included from option.h */ extern const /* CONST_OPTION */ optionValues Option; ... extern int main (int __unused__ argc, char **argv) { ... /* Modification of Option.recurse inside */ parseOptions (args); ... /* Inlined from makeTags */ <read Option.recurse> ... }
As far as variable named 'Option' is defined with 'const' qualificator (using CONST_OPTION), the compiler can move "read Option.recurse" higher than "call parseOptions" while optimization.
This case can be illustrated with the following code:
extern int main (int __unused__ argc, char **argv) { ... <read Option.recurse> ... /* Modification of Option.recurse inside */ parseOptions (args); ... }
This code will work irregularly. For instance, with lcc compiler for Elbrus hardware platform (e2k). For correct code compiling CONST_OPTION macro should be blank. We recommend you to stop using CONST_OPTION macro.