From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 188843858C52; Thu, 29 Feb 2024 11:34:06 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 188843858C52 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1709206446; bh=VKHTaGHyJ94QYy4ajQL6jkoZXUpzsKkPLM8jdmTkXkI=; h=From:To:Subject:Date:From; b=Fjzi+UJAXPwpnoYqvZNGnlW17BN3AtSy9kKf+tXxJLOmcQvYKqDxODPmAhkHnfTkR 5KnwJRDK182mo8zuohY/g+o1Z/1OxkmlO5/RElV5tQopTj5uBY66TZMVXxTHP0bWbc kY7jF/jYMlzQFcnw+gln9w7hGxu+9tFlkARtsx9Y= From: "nabijaczleweli at nabijaczleweli dot xyz" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/114165] New: &scalar+1 and array+1 rejected as template parameters Date: Thu, 29 Feb 2024 11:34:05 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 14.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: nabijaczleweli at nabijaczleweli dot xyz X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D114165 Bug ID: 114165 Summary: &scalar+1 and array+1 rejected as template parameters Product: gcc Version: 14.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: nabijaczleweli at nabijaczleweli dot xyz Target Milestone: --- Given: void consoom(void(*)()); template void withN() {} template void withP() {} static int scalar; static int array[1]; int main() { consoom(withN<&scalar, 1>); consoom(withN); consoom(withP<&scalar, &scalar + 1>); consoom(withP); } clang trunk and gcc trunk -std=3Dc++{11,14,17} agree that=20 : In function 'int main()': :17:12: error: no matches converting function 'withP' to type '= void (*)()' 17 | consoom(withP<&scalar, &scalar + 1>); | ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~ :7:6: note: candidate is: 'template, int* > void withP()' 7 | void withP() {} | ^~~~~ :18:12: error: no matches converting function 'withP' to type '= void (*)()' 18 | consoom(withP); | ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~ :7:6: note: candidate is: 'template, int* > void withP()' 7 | void withP() {} | ^~~~~ Compiler returned: 1 or :17:5: error: no matching function for call to 'consoom' 17 | consoom(withP<&scalar, &scalar + 1>); | ^~~~~~~ :1:6: note: candidate function not viable: no overload of 'with= P' matching 'void (*)()' for 1st argument 1 | void consoom(void(*)()); | ^ ~~~~~~~~~ :18:5: error: no matching function for call to 'consoom' 18 | consoom(withP); | ^~~~~~~ :1:6: note: candidate function not viable: no overload of 'with= P' matching 'void (*)()' for 1st argument 1 | void consoom(void(*)()); | ^ ~~~~~~~~~ 2 errors generated. Compiler returned: 1 clang trunk -std=3Dc++20 accepts the code. GCC trunk -std=3Dc++20 rejects the code with the same error. https://godbolt.org/z/63xzf1MT6 Per my reading of [temp.arg.nontype].6, this is allowed in C++20 because it= 's not rejected by [temp.arg.nontype].6.{1,2,3,4,5}.=