[Bug c++/96330] New: Constexpr variables cannot be used in the template context.
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96330 Bug ID: 96330 Summary: Constexpr variables cannot be used in the template context. Product: gcc Version: 10.1.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: steve_green at qq dot com Target Milestone: --- demo code: struct foo_t { template static constexpr bool bar = true; }; inline constexpr foo_t foo{}; template struct baz { static_assert(foo.bar); // bug in clang (before instantiation) and gcc (during instantiation) static_assert(foo_t::bar); // OK }; int main() { static_assert(foo.bar, ""); // OK static_assert(foo_t::bar, ""); // OK static_cast(baz{}); }
[Bug c++/109142] New: auto tmp=*(data_type*)&v: expected primary-expression before ')' token
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109142 Bug ID: 109142 Summary: auto tmp=*(data_type*)&v: expected primary-expression before ')' token Product: gcc Version: 12.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: steve_green at qq dot com Target Milestone: --- code that trigger errors: https://github.com/ELC-lang/ELC/blob/74495c6e72bc61566d29442ea469e02b4fe223f1/parts/header_file/files/elc/random The specific location where the error was triggered: https://github.com/ELC-lang/ELC/blob/74495c6e72bc61566d29442ea469e02b4fe223f1/parts/_share/basic_environment/_body.hpp#L427 ```text C:\Users\steve02081504\Documents\workstation\ELC_workdirs\ELC>x86_64-w64-mingw32-g++ -v Using built-in specs. COLLECT_GCC=E:\msys\mingw64\bin\x86_64-w64-mingw32-g++.exe COLLECT_LTO_WRAPPER=E:/msys/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/lto-wrapper.exe Target: x86_64-w64-mingw32 Configured with: ../gcc-12.2.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/include --libexecdir=/mingw64/lib --enable-bootstrap --enable-checking=release --with-arch=nocona --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 --enable-libstdcxx-time --disable-libstdcxx-pch --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='Rev10, Built by MSYS2 project' --with-bugurl=https://github.com/msys2/MINGW-packages/issues --with-gnu-as --with-gnu-ld --disable-libstdcxx-debug --with-boot-ldflags=-static-libstdc++ --with-stage1-ldflags=-static-libstdc++ Thread model: posix Supported LTO compression algorithms: zlib zstd gcc version 12.2.0 (Rev10, Built by MSYS2 project) C:\Users\steve02081504\Documents\workstation\ELC_workdirs\ELC>x86_64-w64-mingw32-g++ -x c++ -std=c++23 .\parts\header_file\files\elc\random In file included from .\parts\header_file\files\elc\_files/base_defs/_body.hpp:33, from .\parts\header_file\files\elc\base_defs:50, from .\parts\header_file\files\elc\random:33: .\parts\header_file\files\elc\_files/base_defs/../../../../../_share/basic_environment/_body.hpp: In function 'constexpr auto elc::defs::basic_environment::get_precision(T)': .\parts\header_file\files\elc\_files/base_defs/../../../../../_share/basic_environment/_body.hpp:427:49: error: expected primary-expression before ')' token 427 | auto tmp=*(data_type*)&v; | ^ .\parts\header_file\files\elc\_files/base_defs/../../../../../_share/basic_environment/_body.hpp: In function 'constexpr auto elc::defs::basic_environment::base_get_exponent(T)': .\parts\header_file\files\elc\_files/base_defs/../../../../../_share/basic_environment/_body.hpp:442:49: error: expected primary-expression before ')' token 442 | auto tmp=*(data_type*)&v; | ^ ```
[Bug c++/109142] auto tmp=*(data_type*)&v: expected primary-expression before ')' token
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109142 --- Comment #2 from steve02081504 --- Created attachment 54672 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=54672&action=edit cpp file Here's the pre-processed file you want,hope it helps
[Bug c++/101710] New: Sometimes constexpr cannot be used as constexpr
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101710 Bug ID: 101710 Summary: Sometimes constexpr cannot be used as constexpr Product: gcc Version: 11.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: steve_green at qq dot com Target Milestone: --- Created attachment 51231 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=51231&action=edit .ii file & .s file & output I want to make a minimal reproduction of this ICE, but it seems I can't So allow me to post a link to the project, sorry You can try to compile this file https://github.com/ELC-lang/ELC/blob/master/parts/header_file/test/forICE.cpp In MSVC, the compilation of this file will stop due to some ICE, but it is different from ICEs that GCC have The problem with GCC is that all "error: expected primary-expression before ‘X’ token" can be compiled in MSVC
[Bug c++/101710] Sometimes constexpr cannot be used as constexpr
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101710 steve02081504 changed: What|Removed |Added Attachment #51231|0 |1 is obsolete|| --- Comment #1 from steve02081504 --- Created attachment 51232 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=51232&action=edit .ii file & .s file & output
[Bug c++/101710] Sometimes constexpr cannot be used as constexpr
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101710 --- Comment #4 from steve02081504 --- Created attachment 51235 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=51235&action=edit .ii file & .s file & output - Deflate64 Deflate64 zip added.
[Bug c++/101710] Sometimes constexpr cannot be used as constexpr
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101710 --- Comment #5 from steve02081504 --- (In reply to Andrew Pinski from comment #3) > (In reply to Andrew Pinski from comment #2) > > Can you re-upload the zip file as it seems be corrupted? > > Never mind, I was able to extract it, I had to use winrar rather than the > builtin unziper in windows or Info-ZIP unzip on Linux. Sorry, I think I used LZMA format in the compressed package, which is probably not supported by the standard ZIP format.
[Bug c++/101710] Sometimes constexpr cannot be used as constexpr
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101710 steve02081504 changed: What|Removed |Added Resolution|--- |INVALID Status|UNCONFIRMED |RESOLVED --- Comment #8 from steve02081504 --- (In reply to Andrew Pinski from comment #6) > Changing: > if > constexpr(type_info. > has_attribute_helper()&&type_info. > not_has_has_attribute_helper()) > > to: > if constexpr(type_info.template > has_attribute_helper()&&type_info.template > not_has_has_attribute_helper()) > > Fixes many of the errors > Note the use of template. > > Note there are cases where GCC does not realize the template keyword is not > needed but I don't know if it is actually needed in this case or not. I > suspect it is. So I just need to add "template" to these errors? Well, although it doesn't look very beautiful, I think I latched on This is my code's problem, not GCC's ICE, right thank you
[Bug c++/109169] New: Feature request: Allow omitted template prompts
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109169 Bug ID: 109169 Summary: Feature request: Allow omitted template prompts Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: steve_green at qq dot com Target Milestone: --- I have a third party library that has this write up ```c++ template template struct type_info_t{ //... template static constexpr bool can_convert_to=XXX; //... } template constexpr type_info_ttype_info{}; ``` Since msvc supports such writes, the form of `type_info.can_convert_to`, `compare.able`, `invoke.nothrow` are written throughout the project. Although this is not the standard way of writing, I would expect gcc to support such code.
[Bug c++/109169] Feature request: Allow omitted template prompts
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109169 --- Comment #1 from steve02081504 --- (Corrected code) ```c++ template struct type_info_t{ //... template static constexpr bool can_convert_to=XXX; //... }; template constexpr type_info_ttype_info{}; ```
[Bug c++/109169] Feature request: Allow omitted template prompts
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109169 --- Comment #6 from steve02081504 --- Created attachment 54696 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=54696&action=edit temp.cpp (In reply to Andrew Pinski from comment #4) > You provide a full example of what you want? > Because right now your example your provided does not even compile with msvc. Strangely enough, when I tried to reproduce this requirement, I found that the sample code I had written would compile. ```c++ #include template struct A { template static constexpr bool a = ::std::is_base_of_v; }; template A a{}; int main() { return a.a; } ``` I had no choice but to attach the files I couldn't get to compile and pass in the attachment. I didn't understand whether gcc could compile such things or not..
[Bug c++/109169] Feature request: Allow omitted template prompts
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109169 steve02081504 changed: What|Removed |Added Version|unknown |12.2.0 --- Comment #7 from steve02081504 --- (error&version info) ```text C:\Users\steve02081504\Documents\workstation\ELC_workdirs\ELC>x86_64-w64-mingw32-g++ -v Using built-in specs. COLLECT_GCC=E:\msys\mingw64\bin\x86_64-w64-mingw32-g++.exe COLLECT_LTO_WRAPPER=E:/msys/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/lto-wrapper.exe Target: x86_64-w64-mingw32 Configured with: ../gcc-12.2.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/include --libexecdir=/mingw64/lib --enable-bootstrap --enable-checking=release --with-arch=nocona --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 --enable-libstdcxx-time --disable-libstdcxx-pch --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='Rev10, Built by MSYS2 project' --with-bugurl=https://github.com/msys2/MINGW-packages/issues --with-gnu-as --with-gnu-ld --disable-libstdcxx-debug --with-boot-ldflags=-static-libstdc++ --with-stage1-ldflags=-static-libstdc++ Thread model: posix Supported LTO compression algorithms: zlib zstd gcc version 12.2.0 (Rev10, Built by MSYS2 project) C:\Users\steve02081504\Documents\workstation\ELC_workdirs\ELC>x86_64-w64-mingw32-g++ -x c++ -std=c++23 temp.cpp In file included from .\parts\header_file\files\elc\_files/base_defs/base_defs/_body.hpp:54, from .\parts\header_file\files\elc\_files/base_defs/_body.hpp:53, from .\parts\header_file\files\elc\base_defs:50, from .\parts\header_file\files\elc\random:33: .\parts\header_file\files\elc\_files/base_defs/base_defs/hash.hpp:47:91: error: expected primary-expression before '>' token 47 | concept is_unstable_hash = type_info.can_convert_to; | ^ .\parts\header_file\files\elc\_files/base_defs/base_defs/hash.hpp:47:92: error: expected primary-expression before ';' token 47 | concept is_unstable_hash = type_info.can_convert_to; | ^ In file included from .\parts\header_file\files\elc\_files/base_defs/base_defs/_body.hpp:55: .\parts\header_file\files\elc\_files/base_defs/base_defs/range.hpp:50:74: error: expected primary-expression before '>' token 50 | template requires(type_info.can_convert_to) | ```
[Bug c++/109169] Feature request: Allow omitted template prompts
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109169 --- Comment #9 from steve02081504 --- I don't quite understand why this is correct, can you elaborate on why and how to change the code to bypass the error reporting? Thanks.
[Bug c++/109169] Feature request: Allow omitted template prompts
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109169 --- Comment #11 from steve02081504 --- (In reply to Andrew Pinski from comment #10) > Take: > type_info.can_convert_to > > The first part is dependent so when it goes to parse the next identifier, > the parser does not know that can_convert_to is a template or not. > So it thinks < is the less than operator rather than the start of a template > argument. > > So the fix for the code is: > type_info.template can_convert_to > > Which is the portable fix and even required by the standard to sign to the > compiler the next identifier will start naming of a template. I am not sure if I am making myself clear but msvc can compile such code and that is the reason for my feature request?
[Bug c++/109169] Feature request: Allow omitted template prompts
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109169 --- Comment #14 from steve02081504 --- (In reply to Andrew Pinski from comment #13) > See http://womble.decadent.org.uk/c++/template-faq.html#disambiguation also > to better understand the reason why GCC implements it this way and why it is > hard to implement this "extension" in all cases. But I guess type_info.some_class_name a; is not allowed, right? Only in the case of decltype(type_info)::name do we need to consider whether this is a typename or a template, and in the case of type_info.name this should always be a template?