public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/114915] New: Constrained auto deduction in specialized template scope
@ 2024-05-01 22:53 sska1377 at gmail dot com
  2024-05-01 22:57 ` [Bug c++/114915] " pinskia at gcc dot gnu.org
  0 siblings, 1 reply; 2+ messages in thread
From: sska1377 at gmail dot com @ 2024-05-01 22:53 UTC (permalink / raw)
  To: gcc-bugs

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

            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<typename T>
concept TheConcept = __is_same(T, int);

template<typename T>
void f() {
  TheConcept auto x = 1;
}

/* Here is the problematic function, 
   by removing the specialization below, everything works */
template<>
void f<int>() {
  TheConcept auto x = 1;
}

int main() {
  f<int>();
  return 0;
}

Command: $ g++ report.cpp -std=c++20 -Wall -Wextra -save-temps

Expected: Compilation success
Actual:

report.cpp: In function ‘void f() [with T = int]’:
report.cpp:11:23: error: deduced initializer does not satisfy placeholder
constraints
   11 |   TheConcept auto x = 1;
      |                       ^
report.cpp:11:23: note: constraints not satisfied
report.cpp:2:9:   required for the satisfaction of ‘TheConcept<auto [requires
::TheConcept<<placeholder>, >]>’ [with auto [requires
::TheConcept<<placeholder>, >] = auto [requires ::TheConcept<<placeholder>, >]]
report.cpp:2:22: note:   ‘auto [requires ::TheConcept<<placeholder>, >]’ is not
the same as ‘int’
    2 | concept TheConcept = __is_same(T, int);
      |                      ^~~~~~~~~~~~~~~~~
FAIL

More info:
gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/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=ada,c,c++,d,fortran,go,lto,m2,objc,obj-c++
--enable-bootstrap --prefix=/usr --libdir=/usr/lib --libexecdir=/usr/lib
--mandir=/usr/share/man --infodir=/usr/share/info
--with-bugurl=https://gitlab.archlinux.org/archlinux/packaging/packages/gcc/-/issues
--with-build-config=bootstrap-lto --with-linker-hash-style=gnu
--with-system-zlib --enable-__cxa_atexit --enable-cet=auto
--enable-checking=release --enable-clocale=gnu --enable-default-pie
--enable-default-ssp --enable-gnu-indirect-function --enable-gnu-unique-object
--enable-libstdcxx-backtrace --enable-link-serialization=1
--enable-linker-build-id --enable-lto --enable-multilib --enable-plugin
--enable-shared --enable-threads=posix --disable-libssp --disable-libstdcxx-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 <sska1377 at gmail dot com> ---
A possible fix:

https://gcc.gnu.org/pipermail/gcc-patches/2024-May/650391.html

^ permalink raw reply	[flat|nested] 2+ messages in thread

* [Bug c++/114915] Constrained auto deduction in specialized template scope
  2024-05-01 22:53 [Bug c++/114915] New: Constrained auto deduction in specialized template scope sska1377 at gmail dot com
@ 2024-05-01 22:57 ` pinskia at gcc dot gnu.org
  0 siblings, 0 replies; 2+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-05-01 22:57 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
     Ever confirmed|0                           |1
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2024-05-01

--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Confirmed.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-05-01 22:57 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-05-01 22:53 [Bug c++/114915] New: Constrained auto deduction in specialized template scope sska1377 at gmail dot com
2024-05-01 22:57 ` [Bug c++/114915] " pinskia at gcc dot gnu.org

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).