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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jakub at gcc dot gnu.org,
                   |                            |jason at gcc dot gnu.org,
                   |                            |mpolacek at gcc dot gnu.org

--- Comment #3 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
I think there are multiple issues.  One is the lack of diagnostic for missing
initializer.

I've tried to do:
--- gcc/cp/decl.c.jj    2019-11-16 18:13:28.806818043 +0100
+++ gcc/cp/decl.c       2019-11-19 11:13:03.058266394 +0100
@@ -7500,11 +7500,12 @@ cp_finish_decl (tree decl, tree init, bo
          error ("variable concept has no initializer");
          init = boolean_true_node;
        }
-      else if (init
-              && init_const_expr_p
-              && !TYPE_REF_P (type)
-              && decl_maybe_constant_var_p (decl)
-              && !(dep_init = value_dependent_init_p (init)))
+      else if ((init
+               && init_const_expr_p
+               && !TYPE_REF_P (type)
+               && decl_maybe_constant_var_p (decl)
+               && !(dep_init = value_dependent_init_p (init)))
+              || (!init && !DECL_EXTERNAL (decl)))
        {
          /* This variable seems to be a non-dependent constant, so process
             its initializer.  If check_initializer returns non-null the
but that resulted in
FAIL: g++.dg/cpp2a/concepts-friend3.C  -std=c++17 -fconcepts (test for excess
errors)
FAIL: g++.dg/other/crash-9.C  -std=c++17 -fconcepts (test for excess errors)
FAIL: g++.dg/eh/pr84968.C  -std=gnu++11  (test for errors, line 12)
FAIL: g++.dg/eh/pr84968.C  -std=gnu++11 (test for excess errors)
FAIL: g++.dg/eh/pr84968.C  -std=gnu++14  (test for errors, line 12)
FAIL: g++.dg/eh/pr84968.C  -std=gnu++14 (test for excess errors)
FAIL: g++.dg/eh/pr84968.C  -std=gnu++17  (test for errors, line 12)
FAIL: g++.dg/eh/pr84968.C  -std=gnu++17 (test for excess errors)
FAIL: g++.dg/eh/pr84968.C  -std=gnu++2a  (test for errors, line 12)
FAIL: g++.dg/eh/pr84968.C  -std=gnu++2a (test for excess errors)
FAIL: g++.dg/eh/pr84968.C  -std=gnu++17 -fconcepts  (test for errors, line 12)
FAIL: g++.dg/eh/pr84968.C  -std=gnu++17 -fconcepts (test for excess errors)
FAIL: g++.dg/cpp2a/consteval14.C   (internal compiler error)
FAIL: g++.dg/cpp2a/consteval14.C   (test for excess errors)
FAIL: g++.dg/cpp1y/pr68578.C  -std=c++14 (test for excess errors)
FAIL: g++.dg/cpp1y/pr68578.C  -std=c++17 (test for excess errors)
FAIL: g++.dg/cpp1y/pr68578.C  -std=c++2a (test for excess errors)
FAIL: g++.dg/cpp1y/pr68578.C  -std=c++17 -fconcepts (test for excess errors)
so maybe we'll need something more similar to the present:
      if (!VAR_P (decl) || type_dependent_p)
        /* We can't do anything if the decl has dependent type.  */;
      else if (!init && is_concept_var (decl))
        {
          error ("variable concept has no initializer");
          init = boolean_true_node;
        }
and for !init do parts of grok_reference_init if TYPE_REF_P or call
check_for_uninitialized_const_var.

Another thing is we don't diagnose redefinitions, like:
template <int N> constexpr bool a = false;
template <int N> constexpr bool a = true;
//auto b = a<2>;

Reply via email to