You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This attribute, attached to a variable with static storage, means that the variable must be emitted even if it appears that the variable is not referenced.
Inside a constant "if" condition, clang will fail to emit a "used" variable in the not-taken branch. This differs from GCC behavior.
void foo() {
if (sizeof(double) == sizeof(long double)) {
__attribute__((used)) static int my_item(__LINE__);
} else {
__attribute__((used)) static int my_item(__LINE__);
}
}
Clang allocates only one variable, GCC allocates both. Given it's a GCC-defined attribute, we should behave the way GCC does. This appears to be a Clang codegen bug, as -emit-llvm -disable-llvm-passes shows only one item.
(Why would I need this? It's part of the instrumentation for my Rotten Green Tests project. My static variables are actually allocated into a custom section, but that's not needed to trigger the bug.)
The text was updated successfully, but these errors were encountered:
[GCC](https://gcc.gnu.org/onlinedocs/gcc/Common-Variable-Attributes.html) specifies the "used" attribute as:
> This attribute, attached to a variable with static storage, means that the variable must be emitted even if it appears that the variable is not referenced.
Inside a constant "if" condition, clang will fail to emit a "used" variable in the not-taken branch. This differs from GCC behavior.
void foo() {
if (sizeof(double) == sizeof(long double)) {
__attribute__((used)) static int my_item(__LINE__);
} else {
__attribute__((used)) static int my_item(__LINE__);
}
}
Clang allocates only one variable, GCC allocates both. Given it's a GCC-defined attribute, we should behave the way GCC does. This appears to be a Clang codegen bug, as -emit-llvm -disable-llvm-passes shows only one item.
(Why would I need this? It's part of the instrumentation for my Rotten Green Tests project. My static variables are actually allocated into a custom section, but that's not needed to trigger the bug.)
GCC specifies the "used" attribute as:
Inside a constant "if" condition, clang will fail to emit a "used" variable in the not-taken branch. This differs from GCC behavior.
Clang allocates only one variable, GCC allocates both. Given it's a GCC-defined attribute, we should behave the way GCC does. This appears to be a Clang codegen bug, as
-emit-llvm -disable-llvm-passes
shows only one item.(Why would I need this? It's part of the instrumentation for my Rotten Green Tests project. My static variables are actually allocated into a custom section, but that's not needed to trigger the bug.)
The text was updated successfully, but these errors were encountered: