* [Bug c++/99185] asan initialization-order-fiasco false positive
2021-02-20 23:26 [Bug c++/99185] New: asan initialization-order-fiasco false positive kal.conley at dectris dot com
@ 2021-02-20 23:52 ` kal.conley at dectris dot com
2021-02-21 0:05 ` pinskia at gcc dot gnu.org
` (6 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: kal.conley at dectris dot com @ 2021-02-20 23:52 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99185
--- Comment #1 from kal.conley at dectris dot com ---
Strict init-order checking is enabled.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/99185] asan initialization-order-fiasco false positive
2021-02-20 23:26 [Bug c++/99185] New: asan initialization-order-fiasco false positive kal.conley at dectris dot com
2021-02-20 23:52 ` [Bug c++/99185] " kal.conley at dectris dot com
@ 2021-02-21 0:05 ` pinskia at gcc dot gnu.org
2021-02-21 1:05 ` kal.conley at dectris dot com
` (5 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-02-21 0:05 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99185
--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
I think the error is correct. There is no defined ordering of globalstar
between translation units.
Can you explain why you think the ordering is defined here?
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/99185] asan initialization-order-fiasco false positive
2021-02-20 23:26 [Bug c++/99185] New: asan initialization-order-fiasco false positive kal.conley at dectris dot com
2021-02-20 23:52 ` [Bug c++/99185] " kal.conley at dectris dot com
2021-02-21 0:05 ` pinskia at gcc dot gnu.org
@ 2021-02-21 1:05 ` kal.conley at dectris dot com
2021-02-22 17:01 ` m.cencora at gmail dot com
` (4 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: kal.conley at dectris dot com @ 2021-02-21 1:05 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99185
--- Comment #3 from kal.conley at dectris dot com ---
I don't think there should be any dynamic initialization of A here. Also, its
weird that if the definition if A is changed to:
struct A {
int value = 0;
A() = default;
};
then the error goes away.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/99185] asan initialization-order-fiasco false positive
2021-02-20 23:26 [Bug c++/99185] New: asan initialization-order-fiasco false positive kal.conley at dectris dot com
` (2 preceding siblings ...)
2021-02-21 1:05 ` kal.conley at dectris dot com
@ 2021-02-22 17:01 ` m.cencora at gmail dot com
2021-02-22 17:55 ` kal.conley at dectris dot com
` (3 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: m.cencora at gmail dot com @ 2021-02-22 17:01 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99185
m.cencora at gmail dot com changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |m.cencora at gmail dot com
--- Comment #4 from m.cencora at gmail dot com ---
I think it is just that sanitizer didn't caught up to the C++20 standard where
constexpr was relaxed to allow uninitialized variables.
Constant initialization is applied only when class constructor in constexpr,
and only since C++20 'A' class has constexpr constructor.
Proof, following compiles only since C++20:
struct A {
int value;
constexpr A() = default;
};
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/99185] asan initialization-order-fiasco false positive
2021-02-20 23:26 [Bug c++/99185] New: asan initialization-order-fiasco false positive kal.conley at dectris dot com
` (3 preceding siblings ...)
2021-02-22 17:01 ` m.cencora at gmail dot com
@ 2021-02-22 17:55 ` kal.conley at dectris dot com
2021-02-22 21:08 ` m.cencora at gmail dot com
` (2 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: kal.conley at dectris dot com @ 2021-02-22 17:55 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99185
--- Comment #5 from kal.conley at dectris dot com ---
I don't think this has anything to do with C++20. The behavior doesn't change
when compiling for C++17. In any case, `g` should be static initialized with
zeros and no dynamic initialization in `a.cc` should take place.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/99185] asan initialization-order-fiasco false positive
2021-02-20 23:26 [Bug c++/99185] New: asan initialization-order-fiasco false positive kal.conley at dectris dot com
` (4 preceding siblings ...)
2021-02-22 17:55 ` kal.conley at dectris dot com
@ 2021-02-22 21:08 ` m.cencora at gmail dot com
2021-02-22 21:34 ` kal.conley at dectris dot com
2021-02-22 22:08 ` m.cencora at gmail dot com
7 siblings, 0 replies; 9+ messages in thread
From: m.cencora at gmail dot com @ 2021-02-22 21:08 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99185
--- Comment #6 from m.cencora at gmail dot com ---
Now that I think about and having read relevant chapters of C++20 spec,
observed behavior seems to be expected.
A cannot be constant initialized (because it has missing initializer for
'value' member) so at first zero-initialization is performed as part of static
initialization, then A constructor is called as part of dynamic initialization.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/99185] asan initialization-order-fiasco false positive
2021-02-20 23:26 [Bug c++/99185] New: asan initialization-order-fiasco false positive kal.conley at dectris dot com
` (5 preceding siblings ...)
2021-02-22 21:08 ` m.cencora at gmail dot com
@ 2021-02-22 21:34 ` kal.conley at dectris dot com
2021-02-22 22:08 ` m.cencora at gmail dot com
7 siblings, 0 replies; 9+ messages in thread
From: kal.conley at dectris dot com @ 2021-02-22 21:34 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99185
--- Comment #7 from kal.conley at dectris dot com ---
There is no fiasco here because the default constructor of `A` does no dynamic
initialization. If the definition of `A` is changed to:
struct A {
int value;
};
then the error goes away. However, in both cases there is the same
implicitly-defined default constructor generated by the compiler. Explicitly
declaring `A() = default` should not change anything in this regard. Generating
an error in this case is not useful.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/99185] asan initialization-order-fiasco false positive
2021-02-20 23:26 [Bug c++/99185] New: asan initialization-order-fiasco false positive kal.conley at dectris dot com
` (6 preceding siblings ...)
2021-02-22 21:34 ` kal.conley at dectris dot com
@ 2021-02-22 22:08 ` m.cencora at gmail dot com
7 siblings, 0 replies; 9+ messages in thread
From: m.cencora at gmail dot com @ 2021-02-22 22:08 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99185
--- Comment #8 from m.cencora at gmail dot com ---
It does not matter whether A constructor is default or empty. If class instance
cannot be constant-initialized then dynamic initialization will take place.
I think gcc just incorrectly performs constant initialization in these
scenarios.
clang reports error as expected:
struct A
{
int value;
};
struct B
{
int value;
B() = default;
};
constinit A a;
constinit B b;
^ permalink raw reply [flat|nested] 9+ messages in thread