public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
* [Bug c++/105143] New: ICE when trying to emit a [[nodiscard]] warning @ 2022-04-04 3:02 rl.alt.accnt at gmail dot com 2022-04-06 14:48 ` [Bug c++/105143] c++20: ICE when trying to emit a [[nodiscard]] warning and non-type template arugument ppalka at gcc dot gnu.org ` (4 more replies) 0 siblings, 5 replies; 6+ messages in thread From: rl.alt.accnt at gmail dot com @ 2022-04-04 3:02 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105143 Bug ID: 105143 Summary: ICE when trying to emit a [[nodiscard]] warning Product: gcc Version: 11.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: rl.alt.accnt at gmail dot com Target Milestone: --- I'm getting an internal compiler error when I try to compile the code below: ``` #include <algorithm> #include <type_traits> #include <string> template <size_t sz> struct str_lit { char data[sz]{}; constexpr str_lit(const char (&_data)[sz]) { std::copy_n(_data, sz, data); } template <typename str> constexpr bool operator==(const str& s) const { return sizeof data == sizeof s.data && __builtin_strcmp(data, s.data) == 0; } }; template <str_lit _name, typename _type = std::string> struct option { using type = _type; static constexpr inline decltype(_name) name = _name; }; template <typename... opts> struct command_line_options { template <str_lit s, typename... options> struct type_of; template <str_lit s, typename option, typename option2> struct type_of<s, option, option2> { using type = std::conditional_t<s == option::name, typename option::type, typename option2::type>; }; template <str_lit s, typename option, typename... options> struct type_of<s, option, options...> { using type = std::conditional_t<sizeof...(options) == 0 || s == option::name, typename option::type, typename type_of<s, options...>::type>; }; template <str_lit s> using type_of_t = typename type_of<s, opts...>::type; struct parsed_options { template <str_lit s> [[nodiscard]] type_of_t<s> get() { return {}; } }; }; using options = command_line_options< option<"--filename">, option<"--size", int64_t>>; int main() { options::parsed_options opts; opts.get<"--filename">(); // (void) opts.get<"--filename">(); // Doing this instead works } ``` It seems that this happens while it is trying to emit a warning about the unused return value of `opts.get<"--filename">()` since when I do use it or cast it to (void) it compiles just fine. The same problem also occurs with `[[gnu::warn_unused_result]]` instead of `[[nodiscard]]`. Here's the backtrace: ``` ' Internal compiler error: Error reporting routines re-entered. 0xf3d164 warning(int, char const*, ...) ???:0 0x1190cb1 tsubst(tree_node*, tree_node*, int, tree_node*) ???:0 0x1479e26 pp_format(pretty_printer*, text_info*) ???:0 0xf3d5cf diagnostic_report_diagnostic(diagnostic_context*, diagnostic_info*) ???:0 0xf953af warning_at(unsigned int, int, char const*, ...) ???:0 0x10fa93c convert_to_void(tree_node*, impl_conv_void, int) ???:0 0x10f9d03 finish_expr_stmt(tree_node*) ???:0 0x14e7873 c_parse_file() ???:0 0x14c9d9e c_common_parse_file() ???:0 ``` I'm running gcc 11.2.0 on x86_64 Arch Linux, but I've also tested this with several versions of GCC on compiler explorer including trunk and I ran into much the same problem. Here's a link to that: https://godbolt.org/z/qPY4ccPfr. ^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/105143] c++20: ICE when trying to emit a [[nodiscard]] warning and non-type template arugument 2022-04-04 3:02 [Bug c++/105143] New: ICE when trying to emit a [[nodiscard]] warning rl.alt.accnt at gmail dot com @ 2022-04-06 14:48 ` ppalka at gcc dot gnu.org 2022-04-06 15:46 ` cvs-commit at gcc dot gnu.org ` (3 subsequent siblings) 4 siblings, 0 replies; 6+ messages in thread From: ppalka at gcc dot gnu.org @ 2022-04-06 14:48 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105143 Patrick Palka <ppalka at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Assignee|unassigned at gcc dot gnu.org |ppalka at gcc dot gnu.org CC| |ppalka at gcc dot gnu.org Status|UNCONFIRMED |ASSIGNED Ever confirmed|0 |1 Last reconfirmed| |2022-04-06 --- Comment #1 from Patrick Palka <ppalka at gcc dot gnu.org> --- Confirmed. ^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/105143] c++20: ICE when trying to emit a [[nodiscard]] warning and non-type template arugument 2022-04-04 3:02 [Bug c++/105143] New: ICE when trying to emit a [[nodiscard]] warning rl.alt.accnt at gmail dot com 2022-04-06 14:48 ` [Bug c++/105143] c++20: ICE when trying to emit a [[nodiscard]] warning and non-type template arugument ppalka at gcc dot gnu.org @ 2022-04-06 15:46 ` cvs-commit at gcc dot gnu.org 2022-04-06 15:48 ` ppalka at gcc dot gnu.org ` (2 subsequent siblings) 4 siblings, 0 replies; 6+ messages in thread From: cvs-commit at gcc dot gnu.org @ 2022-04-06 15:46 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105143 --- Comment #2 from CVS Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Patrick Palka <ppalka@gcc.gnu.org>: https://gcc.gnu.org/g:e58484a019c57b1085bbbcc1654f1944feddfe73 commit r12-8028-ge58484a019c57b1085bbbcc1654f1944feddfe73 Author: Patrick Palka <ppalka@redhat.com> Date: Wed Apr 6 11:46:25 2022 -0400 c++: make -Wctad-maybe-unsupported respect complain [PR105143] We were attempting to issue a -Wctad-maybe-unsupported warning even when complain=tf_none, which led to a crash in the first testcase below and a bogus error during overload resolution in the second testcase. PR c++/105143 gcc/cp/ChangeLog: * pt.cc (do_class_deduction): Check complain before attempting to issue a -Wctad-maybe-unsupported warning. gcc/testsuite/ChangeLog: * g++.dg/cpp2a/nodiscard1.C: New test. * g++.dg/warn/Wctad-maybe-unsupported4.C: New test. ^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/105143] c++20: ICE when trying to emit a [[nodiscard]] warning and non-type template arugument 2022-04-04 3:02 [Bug c++/105143] New: ICE when trying to emit a [[nodiscard]] warning rl.alt.accnt at gmail dot com 2022-04-06 14:48 ` [Bug c++/105143] c++20: ICE when trying to emit a [[nodiscard]] warning and non-type template arugument ppalka at gcc dot gnu.org 2022-04-06 15:46 ` cvs-commit at gcc dot gnu.org @ 2022-04-06 15:48 ` ppalka at gcc dot gnu.org 2022-04-07 19:19 ` cvs-commit at gcc dot gnu.org 2022-04-07 19:28 ` ppalka at gcc dot gnu.org 4 siblings, 0 replies; 6+ messages in thread From: ppalka at gcc dot gnu.org @ 2022-04-06 15:48 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105143 Patrick Palka <ppalka at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Target Milestone|--- |11.3 --- Comment #3 from Patrick Palka <ppalka at gcc dot gnu.org> --- Fixed for GCC 12 so far, backport to the 11 branch (for 11.3) to follow. ^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/105143] c++20: ICE when trying to emit a [[nodiscard]] warning and non-type template arugument 2022-04-04 3:02 [Bug c++/105143] New: ICE when trying to emit a [[nodiscard]] warning rl.alt.accnt at gmail dot com ` (2 preceding siblings ...) 2022-04-06 15:48 ` ppalka at gcc dot gnu.org @ 2022-04-07 19:19 ` cvs-commit at gcc dot gnu.org 2022-04-07 19:28 ` ppalka at gcc dot gnu.org 4 siblings, 0 replies; 6+ messages in thread From: cvs-commit at gcc dot gnu.org @ 2022-04-07 19:19 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105143 --- Comment #4 from CVS Commits <cvs-commit at gcc dot gnu.org> --- The releases/gcc-11 branch has been updated by Patrick Palka <ppalka@gcc.gnu.org>: https://gcc.gnu.org/g:4e47b450b72f082de6fba7a060c3a751954e6c17 commit r11-9797-g4e47b450b72f082de6fba7a060c3a751954e6c17 Author: Patrick Palka <ppalka@redhat.com> Date: Wed Apr 6 11:46:25 2022 -0400 c++: make -Wctad-maybe-unsupported respect complain [PR105143] We were attempting to issue a -Wctad-maybe-unsupported warning even when complain=tf_none, which led to a crash in the first testcase below and a bogus error during overload resolution in the second testcase. PR c++/105143 gcc/cp/ChangeLog: * pt.c (do_class_deduction): Check complain before attempting to issue a -Wctad-maybe-unsupported warning. gcc/testsuite/ChangeLog: * g++.dg/cpp2a/nodiscard1.C: New test. * g++.dg/warn/Wctad-maybe-unsupported4.C: New test. (cherry picked from commit e58484a019c57b1085bbbcc1654f1944feddfe73) ^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/105143] c++20: ICE when trying to emit a [[nodiscard]] warning and non-type template arugument 2022-04-04 3:02 [Bug c++/105143] New: ICE when trying to emit a [[nodiscard]] warning rl.alt.accnt at gmail dot com ` (3 preceding siblings ...) 2022-04-07 19:19 ` cvs-commit at gcc dot gnu.org @ 2022-04-07 19:28 ` ppalka at gcc dot gnu.org 4 siblings, 0 replies; 6+ messages in thread From: ppalka at gcc dot gnu.org @ 2022-04-07 19:28 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105143 Patrick Palka <ppalka at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|ASSIGNED |RESOLVED Resolution|--- |FIXED --- Comment #5 from Patrick Palka <ppalka at gcc dot gnu.org> --- Fixed for GCC 11.3/12, thanks for the bug report. ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2022-04-07 19:28 UTC | newest] Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2022-04-04 3:02 [Bug c++/105143] New: ICE when trying to emit a [[nodiscard]] warning rl.alt.accnt at gmail dot com 2022-04-06 14:48 ` [Bug c++/105143] c++20: ICE when trying to emit a [[nodiscard]] warning and non-type template arugument ppalka at gcc dot gnu.org 2022-04-06 15:46 ` cvs-commit at gcc dot gnu.org 2022-04-06 15:48 ` ppalka at gcc dot gnu.org 2022-04-07 19:19 ` cvs-commit at gcc dot gnu.org 2022-04-07 19:28 ` ppalka at gcc dot gnu.org
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).