{"id":2224714,"url":"http://patchwork.ozlabs.org/api/1.1/patches/2224714/?format=json","web_url":"http://patchwork.ozlabs.org/project/gcc/patch/20260417211459.445911-1-polacek@redhat.com/","project":{"id":17,"url":"http://patchwork.ozlabs.org/api/1.1/projects/17/?format=json","name":"GNU Compiler Collection","link_name":"gcc","list_id":"gcc-patches.gcc.gnu.org","list_email":"gcc-patches@gcc.gnu.org","web_url":null,"scm_url":null,"webscm_url":null},"msgid":"<20260417211459.445911-1-polacek@redhat.com>","date":"2026-04-17T21:14:59","name":"c++/reflection: dependent type considered consteval-only [PR124855]","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"685d53fc17ca1dfa3a7eaa6761123ed81a7fd788","submitter":{"id":14370,"url":"http://patchwork.ozlabs.org/api/1.1/people/14370/?format=json","name":"Marek Polacek","email":"polacek@redhat.com"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/gcc/patch/20260417211459.445911-1-polacek@redhat.com/mbox/","series":[{"id":500404,"url":"http://patchwork.ozlabs.org/api/1.1/series/500404/?format=json","web_url":"http://patchwork.ozlabs.org/project/gcc/list/?series=500404","date":"2026-04-17T21:14:59","name":"c++/reflection: dependent type considered consteval-only [PR124855]","version":1,"mbox":"http://patchwork.ozlabs.org/series/500404/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/2224714/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/2224714/checks/","tags":{},"headers":{"Return-Path":"<gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org>","X-Original-To":["incoming@patchwork.ozlabs.org","gcc-patches@gcc.gnu.org"],"Delivered-To":["patchwork-incoming@legolas.ozlabs.org","gcc-patches@gcc.gnu.org"],"Authentication-Results":["legolas.ozlabs.org;\n\tdkim=pass (1024-bit key;\n unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256\n header.s=mimecast20190719 header.b=QsfP4RIC;\n\tdkim-atps=neutral","legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org\n (client-ip=2620:52:6:3111::32; helo=vm01.sourceware.org;\n envelope-from=gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org;\n receiver=patchwork.ozlabs.org)","sourceware.org;\n\tdkim=pass (1024-bit key,\n unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256\n header.s=mimecast20190719 header.b=QsfP4RIC","sourceware.org; dmarc=pass (p=quarantine dis=none)\n header.from=redhat.com","sourceware.org; spf=pass smtp.mailfrom=redhat.com","server2.sourceware.org;\n arc=none smtp.remote-ip=170.10.133.124"],"Received":["from vm01.sourceware.org (vm01.sourceware.org\n [IPv6:2620:52:6:3111::32])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519 server-signature ECDSA (secp384r1) server-digest SHA384)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4fy72q27cvz1yCv\n\tfor <incoming@patchwork.ozlabs.org>; Sat, 18 Apr 2026 07:15:47 +1000 (AEST)","from vm01.sourceware.org (localhost [127.0.0.1])\n\tby sourceware.org (Postfix) with ESMTP id 441354D8D1E9\n\tfor <incoming@patchwork.ozlabs.org>; Fri, 17 Apr 2026 21:15:45 +0000 (GMT)","from us-smtp-delivery-124.mimecast.com\n (us-smtp-delivery-124.mimecast.com [170.10.133.124])\n by sourceware.org (Postfix) with ESMTP id 024A44CCCA23\n for <gcc-patches@gcc.gnu.org>; Fri, 17 Apr 2026 21:15:08 +0000 (GMT)","from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com\n (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by\n relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3,\n cipher=TLS_AES_256_GCM_SHA384) id us-mta-460-X35DaWj8NNKu9rqC_rfCSw-1; Fri,\n 17 Apr 2026 17:15:05 -0400","from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com\n (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111])\n (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest\n SHA256)\n (No client certificate requested)\n by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS\n id C6D05195608F\n for <gcc-patches@gcc.gnu.org>; Fri, 17 Apr 2026 21:15:04 +0000 (UTC)","from pdp-11.lan (unknown [10.22.89.32])\n by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP\n id 2D7061800352; Fri, 17 Apr 2026 21:15:03 +0000 (UTC)"],"DKIM-Filter":["OpenDKIM Filter v2.11.0 sourceware.org 441354D8D1E9","OpenDKIM Filter v2.11.0 sourceware.org 024A44CCCA23"],"DMARC-Filter":"OpenDMARC Filter v1.4.2 sourceware.org 024A44CCCA23","ARC-Filter":"OpenARC Filter v1.0.0 sourceware.org 024A44CCCA23","ARC-Seal":"i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1776460509; cv=none;\n b=C79i1GxtOEMzMvDcITEWXlde4GIJ7/ThJfcBYPax4AuRTlUfvD40f6+bHWncA4kiUsh+GGtLS0O2o6cmPIZwm3cvCE38QKu2eCh9b6Uf3wJoHstWmliO0HP0ov32lPrIppob6DIBdMXAi7wOsG5f+zUZdDMMYDwkvPh/IC6DnQM=","ARC-Message-Signature":"i=1; a=rsa-sha256; d=sourceware.org; s=key;\n t=1776460509; c=relaxed/simple;\n bh=csiAhYrQWN8muYohCg+NrmasLy2PuloLduiMFptlWmw=;\n h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version;\n b=KqWc2U4Dy/isVvgbU/pJ6XbsHdfOmN/XyKgqJkrtcmc0PtB7hIVdKnpDhLM6/8Vwj9Rm7CcU+W0Rpp9tDy4NaUlLbArZP2T/IIyGQWs9c7kZ0TFnFh6Tf2hsI3ZDbs/uGdZ1IDA+OxpcIxxitELHo+rcXamMfeSFZvUlaMaUtgI=","ARC-Authentication-Results":"i=1; server2.sourceware.org","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com;\n s=mimecast20190719; t=1776460508;\n h=from:from:reply-to:subject:subject:date:date:message-id:message-id:\n to:to:cc:mime-version:mime-version:content-type:content-type:\n content-transfer-encoding:content-transfer-encoding;\n bh=/Kovd0PjpPRMRKjoAeCW2NdGX8246NSF+oolkWASo0A=;\n b=QsfP4RICLmu0D3jv7GOLLVSGP7eiROqxdqPliI4LeiGLzLF7YS39GMoXQd4VA/VMt25F+p\n 6alML513gzSZiDNTAIea+WYB6P7T00A009LB7p7SXgWZkfv8suExqajVg639ULsYXSEZZY\n y2axriLU9YYTcCpXuwL3wapOM6M3T54=","X-MC-Unique":"X35DaWj8NNKu9rqC_rfCSw-1","X-Mimecast-MFC-AGG-ID":"X35DaWj8NNKu9rqC_rfCSw_1776460505","From":"Marek Polacek <polacek@redhat.com>","To":"GCC Patches <gcc-patches@gcc.gnu.org>, Jason Merrill <jason@redhat.com>,\n Jakub Jelinek <jakub@redhat.com>","Subject":"[PATCH] c++/reflection: dependent type considered consteval-only\n [PR124855]","Date":"Fri, 17 Apr 2026 17:14:59 -0400","Message-ID":"<20260417211459.445911-1-polacek@redhat.com>","MIME-Version":"1.0","X-Scanned-By":"MIMEDefang 3.4.1 on 10.30.177.111","X-Mimecast-Spam-Score":"0","X-Mimecast-MFC-PROC-ID":"1q1HCOxVATBlREr5JCUCmeKMkp_i_MAkebrZ9DBOV44_1776460505","X-Mimecast-Originator":"redhat.com","Content-Transfer-Encoding":"8bit","content-type":"text/plain; charset=\"US-ASCII\"; x-default=true","X-BeenThere":"gcc-patches@gcc.gnu.org","X-Mailman-Version":"2.1.30","Precedence":"list","List-Id":"Gcc-patches mailing list <gcc-patches.gcc.gnu.org>","List-Unsubscribe":"<https://gcc.gnu.org/mailman/options/gcc-patches>,\n <mailto:gcc-patches-request@gcc.gnu.org?subject=unsubscribe>","List-Archive":"<https://gcc.gnu.org/pipermail/gcc-patches/>","List-Post":"<mailto:gcc-patches@gcc.gnu.org>","List-Help":"<mailto:gcc-patches-request@gcc.gnu.org?subject=help>","List-Subscribe":"<https://gcc.gnu.org/mailman/listinfo/gcc-patches>,\n <mailto:gcc-patches-request@gcc.gnu.org?subject=subscribe>","Errors-To":"gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org"},"content":"Bootstrapped/regtested on x86_64-pc-linux-gnu, ok for trunk?\n\n-- >8 --\nHere we emit the \"function of consteval-only type must be declared\n'consteval'\" error for f, even though its type will become\nchar f(int) after substitution, which is not consteval-only.  We\nprobably shouldn't consider dependent type consteval-only.\n\n\tPR c++/124855\n\ngcc/cp/ChangeLog:\n\n\t* reflect.cc (consteval_only_p): Return false if the type is\n\tdependent.\n\ngcc/testsuite/ChangeLog:\n\n\t* g++.dg/reflect/type11.C: New test.\n---\n gcc/cp/reflect.cc                     |  4 ++++\n gcc/testsuite/g++.dg/reflect/type11.C | 10 ++++++++++\n 2 files changed, 14 insertions(+)\n create mode 100644 gcc/testsuite/g++.dg/reflect/type11.C\n\n\nbase-commit: dd723b26663c76440ae44e83f0c699240c75b81e","diff":"diff --git a/gcc/cp/reflect.cc b/gcc/cp/reflect.cc\nindex 97b6e76c652..167123b3f2d 100644\n--- a/gcc/cp/reflect.cc\n+++ b/gcc/cp/reflect.cc\n@@ -8630,6 +8630,10 @@ consteval_only_p (tree t)\n      which could be consteval-only, depending on T.  */\n   t = complete_type (t);\n \n+  /* For dependent types we can't be sure if this type is consteval-only.  */\n+  if (dependent_type_p (t))\n+    return false;\n+\n   /* Classes with std::meta::info members are also consteval-only.  */\n   hash_set<tree> visited;\n   return !!cp_walk_tree (&t, consteval_only_type_r, &visited, &visited);\ndiff --git a/gcc/testsuite/g++.dg/reflect/type11.C b/gcc/testsuite/g++.dg/reflect/type11.C\nnew file mode 100644\nindex 00000000000..11024ff4606\n--- /dev/null\n+++ b/gcc/testsuite/g++.dg/reflect/type11.C\n@@ -0,0 +1,10 @@\n+// PR c++/124855\n+// { dg-do compile { target c++26 } }\n+// { dg-additional-options \"-freflection\" }\n+\n+using mi = decltype(^^::);\n+\n+template<class T>\n+auto f(T) -> [: ^^T == ^^int ? ^^char : mi{} :];\n+\n+static_assert(sizeof(f(0)) == 1);\n","prefixes":[]}