[Bug c++/101631] gcc permits object reference to object outside of its lifetime during constant evaluation

2021-07-27 Thread redi at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101631

--- Comment #3 from Jonathan Wakely  ---
(In reply to fsb4000 from comment #2)
> I'm confused with "What we do not want: Bugs in releases or snapshots of GCC
> not issued by the GNU Project. Report them to whoever provided you with the
> release".

10.3.0 is an official release. 10.3.1 or some heavily patched GCC would not be.

[Bug c++/101631] gcc permits object reference to object outside of its lifetime during constant evaluation

2021-07-27 Thread rguenth at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101631

Richard Biener  changed:

   What|Removed |Added

 Ever confirmed|1   |0
 Status|WAITING |UNCONFIRMED
   Keywords||accepts-invalid

[Bug c++/101631] gcc permits object reference to object outside of its lifetime during constant evaluation

2021-07-26 Thread fsb4000 at yandex dot ru via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101631

--- Comment #2 from fsb4000 at yandex dot ru ---
Sure.

$ g++ -c -std=c++20 -save-temps main.cpp

$ g++ -v
Using built-in specs.
COLLECT_GCC=C:\tools\msys64\mingw64\bin\g++.exe
COLLECT_LTO_WRAPPER=C:/tools/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/lto-wrapper.exe
Target: x86_64-w64-mingw32
Configured with: ../gcc-10.3.0/configure --prefix=/mingw64
--with-local-prefix=/mingw64/local --build=x86_64-w64-mingw32
--host=x86_64-w64-mingw32 --target=x86_64-w64-mingw32
--with-native-system-header-dir=/mingw64/x86_64-w64-mingw32/include
--libexecdir=/mingw64/lib --enable-bootstrap --enable-checking=release
--with-arch=x86-64 --with-tune=generic
--enable-languages=c,lto,c++,fortran,ada,objc,obj-c++,jit --enable-shared
--enable-static --enable-libatomic --enable-threads=posix --enable-graphite
--enable-fully-dynamic-string --enable-libstdcxx-filesystem-ts=yes
--enable-libstdcxx-time=yes --disable-libstdcxx-pch --disable-libstdcxx-debug
--enable-lto --enable-libgomp --disable-multilib --disable-rpath
--disable-win32-registry --disable-nls --disable-werror --disable-symvers
--with-libiconv --with-system-zlib --with-gmp=/mingw64 --with-mpfr=/mingw64
--with-mpc=/mingw64 --with-isl=/mingw64 --with-pkgversion='Rev5, Built by MSYS2
project' --with-bugurl=https://github.com/msys2/MINGW-packages/issues
--with-gnu-as --with-gnu-ld --with-boot-ldflags='-pipe
-Wl,--dynamicbase,--high-entropy-va,--nxcompat,--default-image-base-high
-Wl,--disable-dynamicbase -static-libstdc++ -static-libgcc'
'LDFLAGS_FOR_TARGET=-pipe
-Wl,--dynamicbase,--high-entropy-va,--nxcompat,--default-image-base-high'
--enable-linker-plugin-flags='LDFLAGS=-static-libstdc++\ -static-libgcc\ -pipe\
-Wl,--dynamicbase,--high-entropy-va,--nxcompat,--default-image-base-high\
-Wl,--stack,12582912'
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 10.3.0 (Rev5, Built by MSYS2 project)

$ cat main.ii
# 1 "main.cpp"
# 1 ""
# 1 ""
# 1 "main.cpp"
struct sso {
union {
int buf[10];
int* alloc;
};
};

constexpr bool test_switch() noexcept {
sso val;
val.alloc = nullptr;
val.buf[5] = 42;
return true;
}
static_assert(test_switch());

constexpr void perform_assignment(int& left, int right) noexcept {
left = right;
}

constexpr bool test_switch_with_indirection() noexcept {
sso val;
val.alloc = nullptr;
perform_assignment(val.buf[5], 42);
return true;
}
static_assert(test_switch_with_indirection());


Expected: 

static_assert(test_switch_with_indirection());

should fail.

Sceenshot(just in case ): https://imgur.com/a/DXYYq1y

My OS: Windows 10 Pro 64 bit, 21H1


I'm confused with "What we do not want: Bugs in releases or snapshots of GCC
not issued by the GNU Project. Report them to whoever provided you with the
release".
What should I do? I can check at godbolt.org or locally using gcc from msys2.
But it's stupid to report gcc bugs to people working on godbolt.org or msys2.
They are not gcc developers. 

BTW the bug report in the first comment is almost identical to bug report we
sent to Visual C++ developers:
https://developercommunity.visualstudio.com/t/cl-permits-object-reference-to-object-outside-of-i/1487178
(just cl instead of gcc)

[Bug c++/101631] gcc permits object reference to object outside of its lifetime during constant evaluation

2021-07-26 Thread redi at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101631

Jonathan Wakely  changed:

   What|Removed |Added

 Status|UNCONFIRMED |WAITING
 Ever confirmed|0   |1
   Last reconfirmed||2021-07-26

--- Comment #1 from Jonathan Wakely  ---
(In reply to fsb4000 from comment #0)
> (Obligatory godbolt: https://godbolt.org/z/6qG7v9eYx)

Godbolt links are not obligatory, but a testcase is. See
https://gcc.gnu.org/bugs