From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id D763E384AB4F; Wed, 1 May 2024 22:53:22 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D763E384AB4F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1714604002; bh=CaW/E1fiP9ufzy84p+I1gFevfQySFWu6s+aZvp6+da0=; h=From:To:Subject:Date:From; b=G7I3iKPOLMUN95q7KyV8K96k4xWXKvYZ/6we5zNFNwF6ehi/kmZlkl9WCAYrCj9vZ DON0vV8WHmB4rwCn37MIoDZUGXbBELrr7hSsFG4g2ZNoIwd9IAAS6Eg8h/TBkw5/Qt yj6AlSEIJr4/XcN/9FBs7UtueZUyFpRN6G5p3qpg= From: "sska1377 at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/114915] New: Constrained auto deduction in specialized template scope Date: Wed, 01 May 2024 22:53:22 +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: 13.2.1 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: sska1377 at gmail dot com 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=3D114915 Bug ID: 114915 Summary: Constrained auto deduction in specialized template scope Product: gcc Version: 13.2.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: sska1377 at gmail dot com Target Milestone: --- Here is a simple code that uses constrained auto deduction in a template specialization scope. By removing the specialization, the code compiles successfully. However, with the specialization, the code fails to compile, = even though both cases should be equivalent. Code: template concept TheConcept =3D __is_same(T, int); template void f() { TheConcept auto x =3D 1; } /* Here is the problematic function,=20 by removing the specialization below, everything works */ template<> void f() { TheConcept auto x =3D 1; } int main() { f(); return 0; } Command: $ g++ report.cpp -std=3Dc++20 -Wall -Wextra -save-temps Expected: Compilation success Actual: report.cpp: In function =E2=80=98void f() [with T =3D int]=E2=80=99: report.cpp:11:23: error: deduced initializer does not satisfy placeholder constraints 11 | TheConcept auto x =3D 1; | ^ report.cpp:11:23: note: constraints not satisfied report.cpp:2:9: required for the satisfaction of =E2=80=98TheConcept, >]>=E2=80=99 [with auto [requires ::TheConcept<, >] =3D auto [requires ::TheConcept<, >]] report.cpp:2:22: note: =E2=80=98auto [requires ::TheConcept<= , >]=E2=80=99 is not the same as =E2=80=98int=E2=80=99 2 | concept TheConcept =3D __is_same(T, int); | ^~~~~~~~~~~~~~~~~ FAIL More info: gcc -v Using built-in specs. COLLECT_GCC=3Dgcc COLLECT_LTO_WRAPPER=3D/usr/lib/gcc/x86_64-pc-linux-gnu/13.2.1/lto-wrapper Target: x86_64-pc-linux-gnu Configured with: /build/gcc/src/gcc/configure --enable-languages=3Dada,c,c++,d,fortran,go,lto,m2,objc,obj-c++ --enable-bootstrap --prefix=3D/usr --libdir=3D/usr/lib --libexecdir=3D/usr/= lib --mandir=3D/usr/share/man --infodir=3D/usr/share/info --with-bugurl=3Dhttps://gitlab.archlinux.org/archlinux/packaging/packages/g= cc/-/issues --with-build-config=3Dbootstrap-lto --with-linker-hash-style=3Dgnu --with-system-zlib --enable-__cxa_atexit --enable-cet=3Dauto --enable-checking=3Drelease --enable-clocale=3Dgnu --enable-default-pie --enable-default-ssp --enable-gnu-indirect-function --enable-gnu-unique-obj= ect --enable-libstdcxx-backtrace --enable-link-serialization=3D1 --enable-linker-build-id --enable-lto --enable-multilib --enable-plugin --enable-shared --enable-threads=3Dposix --disable-libssp --disable-libstdc= xx-pch --disable-werror Thread model: posix Supported LTO compression algorithms: zlib zstd gcc version 13.2.1 20240417 (GCC) --- Comment #1 from Seyed Sajad Kahani --- A possible fix: https://gcc.gnu.org/pipermail/gcc-patches/2024-May/650391.html=