public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "marxin at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/101029] unexpected error: non-constant condition for static assertion in gcc 10/11, but not 9 (clang also fine)
Date: Fri, 11 Jun 2021 13:41:36 +0000	[thread overview]
Message-ID: <bug-101029-4-jCL78Tfn5Y@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-101029-4@http.gcc.gnu.org/bugzilla/>

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101029

--- Comment #4 from Martin Liška <marxin at gcc dot gnu.org> ---
Created attachment 50985
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=50985&action=edit
test-case

I see the following issue when not using an optimization level:

$ g++ gcc_issue.cc -c
gcc_issue.cc: In instantiation of ‘struct is_default_constructible<int>’:
gcc_issue.cc:10:8:   required from ‘struct
__and_<is_default_constructible<int>, int, int>’
gcc_issue.cc:29:57:   required by substitution of ‘template<class _U1, class
_U2, typename enable_if<__and_<is_default_constructible<_U1>, _U2,
int>::valuebool>::type <anonymous> > pair::pair() [with _U1 = int; _U2 = int;
typename enable_if<__and_<is_default_constructible<_U1>, _U2,
int>::valuebool>::type <anonymous> = <missing>]’
:126:31:   required from here
gcc_issue.cc:18:43: error: non-constant condition for static assertion
   18 |   static_assert(__is_complete_or_unbounded(_Tp{}));
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~
gcc_issue.cc:18:43:   in ‘constexpr’ expansion of
‘__is_complete_or_unbounded<int>(0).integral_constant<1>::operator
integral_constant<1>::value_type()’
gcc_issue.cc:18:43: internal compiler error: in cxx_eval_call_expression, at
cp/constexpr.c:2701
0x65e879 cxx_eval_call_expression
        /home/marxin/Programming/gcc/gcc/cp/constexpr.c:2701
0x9a0489 cxx_eval_constant_expression
        /home/marxin/Programming/gcc/gcc/cp/constexpr.c:6232
0x9acc6d cxx_eval_binary_expression
        /home/marxin/Programming/gcc/gcc/cp/constexpr.c:3187
0x99f86a cxx_eval_constant_expression
        /home/marxin/Programming/gcc/gcc/cp/constexpr.c:6590
0x9a3f47 cxx_eval_outermost_constant_expr
        /home/marxin/Programming/gcc/gcc/cp/constexpr.c:7264
0xb955e9 finish_static_assert(tree_node*, tree_node*, unsigned int, bool, bool)
        /home/marxin/Programming/gcc/gcc/cp/semantics.c:10306
0xb55ec3 tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool)
        /home/marxin/Programming/gcc/gcc/cp/pt.c:18644
0xb55ec3 tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool)
        /home/marxin/Programming/gcc/gcc/cp/pt.c:18096
0xb710e9 instantiate_class_template_1
        /home/marxin/Programming/gcc/gcc/cp/pt.c:12009
0xb710e9 instantiate_class_template(tree_node*)
        /home/marxin/Programming/gcc/gcc/cp/pt.c:12268
0xbbfe17 complete_type(tree_node*)
        /home/marxin/Programming/gcc/gcc/cp/typeck.c:143
0xbbfe17 complete_type(tree_node*)
        /home/marxin/Programming/gcc/gcc/cp/typeck.c:111
0xb7d116 lookup_member(tree_node*, tree_node*, int, bool, int,
access_failure_info*)
        /home/marxin/Programming/gcc/gcc/cp/search.c:1148
0xabbe97 lookup_qualified_name(tree_node*, tree_node*, LOOK_want, bool)
        /home/marxin/Programming/gcc/gcc/cp/name-lookup.c:7113
0xb366f9 tsubst_qualified_id
        /home/marxin/Programming/gcc/gcc/cp/pt.c:16364
0xb3889b tsubst_copy_and_build(tree_node*, tree_node*, int, tree_node*, bool,
bool)
        /home/marxin/Programming/gcc/gcc/cp/pt.c:19839
0xb54186 tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool)
        /home/marxin/Programming/gcc/gcc/cp/pt.c:19082
0xb54186 tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool)
        /home/marxin/Programming/gcc/gcc/cp/pt.c:18096
0xb5bf55 tsubst_template_arg(tree_node*, tree_node*, int, tree_node*)
        /home/marxin/Programming/gcc/gcc/cp/pt.c:12286
0xb5bf55 tsubst_template_arg(tree_node*, tree_node*, int, tree_node*)
        /home/marxin/Programming/gcc/gcc/cp/pt.c:12274
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.


while -O is fine:

$ g++ gcc_issue.cc -c -O

  parent reply	other threads:[~2021-06-11 13:41 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-11 12:04 [Bug c++/101029] New: " jim.w.walker at gmail dot com
2021-06-11 12:05 ` [Bug c++/101029] " jim.w.walker at gmail dot com
2021-06-11 12:17 ` marxin at gcc dot gnu.org
2021-06-11 12:22 ` redi at gcc dot gnu.org
2021-06-11 13:41 ` marxin at gcc dot gnu.org [this message]
2021-06-11 13:42 ` marxin at gcc dot gnu.org
2021-06-11 20:45 ` jason at gcc dot gnu.org
2021-06-11 22:20 ` [Bug c++/101029] [10/11/12 regression] " jason at gcc dot gnu.org
2021-06-12 16:40 ` cvs-commit at gcc dot gnu.org
2021-06-16  9:03 ` jim.w.walker at gmail dot com
2021-06-16  9:16 ` redi at gcc dot gnu.org
2021-06-16 18:33 ` cvs-commit at gcc dot gnu.org
2021-06-17  3:38 ` cvs-commit at gcc dot gnu.org
2021-06-17  3:39 ` cvs-commit at gcc dot gnu.org
2021-06-17  3:39 ` cvs-commit at gcc dot gnu.org
2021-07-06  6:49 ` rguenth at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-101029-4-jCL78Tfn5Y@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).