Re: [PATCH v2] c++: side effect in nullptr_t conversion fix

2024-01-18 Thread Dmitry Drozodv
r(); +} +/* non-constant init: no store bar() result to a_2. Call bar() and init a_2 by zero. */ +// { dg-final { scan-tree-dump-times "bar \\(\\);, a_2 = 0;" 1 "original"} } -- 2.34.1 On Wed, Jan 17, 2024 at 12:10 AM Jason Merrill wrote: > On 1/11/24 15:34, Dmitry Drozodv

[PATCH v2] c++: side effect in nullptr_t conversion fix

2024-01-11 Thread Dmitry Drozodv
Hello, You are absolutely right, we can't throw all side-effects away. Example: ```c++ auto __attribute__ ((noinline)) bar() { volatile int* b = (int *)0xff; *b = 10; volatile auto n = nullptr; return n; // Problem (1) } int* foo_2() { volatile

[PATCH] c++: side effect in nullptr_t conversion fix

2024-01-09 Thread Dmitry Drozodv
According C++ standard [conv.lval]p3.1: If T is cv std::nullptr_t, the result is a null pointer constant. [Note: Since the conversion does not access the object to which the glvalue refers, there is no side effect even if T is volatile-qualified, and the glvalue can refer to an inactive member of