public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/96830] New: GCC does not complain template-head containing requires clause
@ 2020-08-28  8:39 p.hyundeok76 at gmail dot com
  2020-08-28 11:13 ` [Bug c++/96830] " redi at gcc dot gnu.org
                   ` (16 more replies)
  0 siblings, 17 replies; 18+ messages in thread
From: p.hyundeok76 at gmail dot com @ 2020-08-28  8:39 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 96830
           Summary: GCC does not complain template-head containing
                    requires clause
           Product: gcc
           Version: 10.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: p.hyundeok76 at gmail dot com
  Target Milestone: ---

Created attachment 49145
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=49145&action=edit
output of g++-10 -v -save-temps -std=c++2a test.cpp

Summary

When the member of a class template containing requires clause is defined
outside the class, the code compiles although the definition does not specify
the requires clause.

Consider the code snippet below:

template<typename Container>
    requires std::integral<typename Container::value_type>
class Foo {
public:
    void func();
};

template<typename Container>
void Foo<Container>::func()
{}

As shown above, the definition of Foo<T>::func does not contain requires
clause. But it compiles without an error.

When compiled with clang, it complains.

- version of GCC (tested on two machines)
1.
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/9/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none:hsa
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 9.3.0-10ubuntu2'
--with-bugurl=file:///usr/share/doc/gcc-9/README.Bugs
--enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++,gm2 --prefix=/usr
--with-gcc-major-version-only --program-suffix=-9
--program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id
--libexecdir=/usr/lib --without-included-gettext --enable-threads=posix
--libdir=/usr/lib --enable-nls --enable-clocale=gnu --enable-libstdcxx-debug
--enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new
--enable-gnu-unique-object --disable-vtable-verify --enable-plugin
--enable-default-pie --with-system-zlib --with-target-system-zlib=auto
--enable-objc-gc=auto --enable-multiarch --disable-werror --with-arch-32=i686
--with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib
--with-tune=generic --enable-offload-targets=nvptx-none,hsa
--without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu
--host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 9.3.0 (Ubuntu 9.3.0-10ubuntu2)

2.
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-pc-linux-gnu/10.2.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: /build/gcc/src/gcc/configure --prefix=/usr --libdir=/usr/lib
--libexecdir=/usr/lib --mandir=/usr/share/man --infodir=/usr/share/info
--with-bugurl=https://bugs.archlinux.org/
--enable-languages=c,c++,ada,fortran,go,lto,objc,obj-c++,d --with-isl
--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-install-libiberty --enable-linker-build-id
--enable-lto --enable-multilib --enable-plugin --enable-shared
--enable-threads=posix --disable-libssp --disable-libstdcxx-pch
--disable-libunwind-exceptions --disable-werror
gdc_include_dir=/usr/include/dlang/gdc
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 10.2.0 (GCC)

- system (output of uname -a excluding dates)
1. 4.4.0-18362-Microsoft #836-Microsoft x86_64 x86_64 x86_64 GNU/Linux
2. Linux arch 5.8.3-arch1-1 x86_64 GNU/Linux

- options used for compilation
-std=c++2a

- command line that triggers the bug
g++ -std=c++2a test.cpp

- compiler output
Nothing

- preprocessed file (generated on the first system)
test.ii

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

* [Bug c++/96830] GCC does not complain template-head containing requires clause
  2020-08-28  8:39 [Bug c++/96830] New: GCC does not complain template-head containing requires clause p.hyundeok76 at gmail dot com
@ 2020-08-28 11:13 ` redi at gcc dot gnu.org
  2020-08-28 11:24 ` redi at gcc dot gnu.org
                   ` (15 subsequent siblings)
  16 siblings, 0 replies; 18+ messages in thread
From: redi at gcc dot gnu.org @ 2020-08-28 11:13 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Reduced:

template<typename T> concept C = requires { typename T::value_type; };

template<typename Container>
    requires C<Container>
class Foo {
public:
    void func();
};

template<typename Container>
void Foo<Container>::func()
{}


EDG compiles it without error too. Clang says:

96830.C:10:1: error: requires clause differs in template redeclaration
template<typename Container>
^
96830.C:4:14: note: previous template declaration is here
    requires C<Container>
             ^
1 error generated.

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

* [Bug c++/96830] GCC does not complain template-head containing requires clause
  2020-08-28  8:39 [Bug c++/96830] New: GCC does not complain template-head containing requires clause p.hyundeok76 at gmail dot com
  2020-08-28 11:13 ` [Bug c++/96830] " redi at gcc dot gnu.org
@ 2020-08-28 11:24 ` redi at gcc dot gnu.org
  2020-08-28 11:26 ` redi at gcc dot gnu.org
                   ` (14 subsequent siblings)
  16 siblings, 0 replies; 18+ messages in thread
From: redi at gcc dot gnu.org @ 2020-08-28 11:24 UTC (permalink / raw)
  To: gcc-bugs

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

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
     Ever confirmed|0                           |1
           Keywords|                            |accepts-invalid
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2020-08-28

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

* [Bug c++/96830] GCC does not complain template-head containing requires clause
  2020-08-28  8:39 [Bug c++/96830] New: GCC does not complain template-head containing requires clause p.hyundeok76 at gmail dot com
  2020-08-28 11:13 ` [Bug c++/96830] " redi at gcc dot gnu.org
  2020-08-28 11:24 ` redi at gcc dot gnu.org
@ 2020-08-28 11:26 ` redi at gcc dot gnu.org
  2022-07-20  9:54 ` redi at gcc dot gnu.org
                   ` (13 subsequent siblings)
  16 siblings, 0 replies; 18+ messages in thread
From: redi at gcc dot gnu.org @ 2020-08-28 11:26 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> ---
G++ still accepts this version, though EDG and Clang reject it:

template<typename T> concept C = requires { typename T::value_type; };

template<C Container>
class Foo {
public:
    void func();
};

template<typename Container>
void Foo<Container>::func()
{}


$ edg --c++20 -c 96830.C
"96830.C", line 10: error: template argument list must match the parameter list
  void Foo<Container>::func()
       ^

1 error detected in the compilation of "96830.C".

$ clang++ -std=c++2a -c 96830.C
96830.C:9:10: error: type constraint differs in template redeclaration
template<typename Container>
         ^
96830.C:3:10: note: previous template declaration is here
template<C Container>
         ^
1 error generated.

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

* [Bug c++/96830] GCC does not complain template-head containing requires clause
  2020-08-28  8:39 [Bug c++/96830] New: GCC does not complain template-head containing requires clause p.hyundeok76 at gmail dot com
                   ` (2 preceding siblings ...)
  2020-08-28 11:26 ` redi at gcc dot gnu.org
@ 2022-07-20  9:54 ` redi at gcc dot gnu.org
  2022-07-20 22:59 ` [Bug c++/96830] GCC does not complain about redeclaration with inconsistent " cvs-commit at gcc dot gnu.org
                   ` (12 subsequent siblings)
  16 siblings, 0 replies; 18+ messages in thread
From: redi at gcc dot gnu.org @ 2022-07-20  9:54 UTC (permalink / raw)
  To: gcc-bugs

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

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|2020-08-28 00:00:00         |2022-7-20

--- Comment #3 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Another examples:

template<class T> requires true
struct S
{
  template<class U>
    friend struct S;
};

S<int> s;



EDG:

"diff.C", line 5: error: requires-clause incompatible with class template "S"
          (declared at line 2)
      friend struct S;
                    ^
          detected during instantiation of class "S<T> [with T=int]" at line 8

1 error detected in the compilation of "diff.C".


Clang:

diff.C:4:3: error: requires clause differs in template redeclaration
  template<class U>
  ^
diff.C:8:8: note: in instantiation of template class 'S<int>' requested here
S<int> s;
       ^
diff.C:1:28: note: previous template declaration is here
template<class T> requires true
                           ^
1 error generated.

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

* [Bug c++/96830] GCC does not complain about redeclaration with inconsistent requires clause
  2020-08-28  8:39 [Bug c++/96830] New: GCC does not complain template-head containing requires clause p.hyundeok76 at gmail dot com
                   ` (3 preceding siblings ...)
  2022-07-20  9:54 ` redi at gcc dot gnu.org
@ 2022-07-20 22:59 ` cvs-commit at gcc dot gnu.org
  2022-07-21 11:17 ` cvs-commit at gcc dot gnu.org
                   ` (11 subsequent siblings)
  16 siblings, 0 replies; 18+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-07-20 22:59 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jonathan Wakely <redi@gcc.gnu.org>:

https://gcc.gnu.org/g:3b5567c3ec7e5759bdecc6a6fc0be2b65a93636e

commit r13-1769-g3b5567c3ec7e5759bdecc6a6fc0be2b65a93636e
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Wed Jul 20 12:49:28 2022 +0100

    libstdc++: Fix minor bugs in std::common_iterator

    The noexcept-specifier for some std::common_iterator constructors was
    incorrectly using an rvalue as the first argument of
    std::is_nothrow_assignable_v. This gave the wrong answer for some types,
    e.g. std::common_iterator<int*, S>, because an rvalue of scalar type
    cannot be assigned to.

    Also fix the friend declaration to use the same constraints as on the
    definition of the class template. G++ fails to diagnose this error, due
    to PR c++/96830.

    Finally, the copy constructor was using std::move for its argument
    in some cases, which should be removed.

    libstdc++-v3/ChangeLog:

            * include/bits/stl_iterator.h (common_iterator): Fix incorrect
            uses of is_nothrow_assignable_v. Fix inconsistent constraints on
            friend declaration. Do not move argument in copy constructor.
            * testsuite/24_iterators/common_iterator/1.cc: Check for
            noexcept constructibnle/assignable.

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

* [Bug c++/96830] GCC does not complain about redeclaration with inconsistent requires clause
  2020-08-28  8:39 [Bug c++/96830] New: GCC does not complain template-head containing requires clause p.hyundeok76 at gmail dot com
                   ` (4 preceding siblings ...)
  2022-07-20 22:59 ` [Bug c++/96830] GCC does not complain about redeclaration with inconsistent " cvs-commit at gcc dot gnu.org
@ 2022-07-21 11:17 ` cvs-commit at gcc dot gnu.org
  2022-07-22  7:07 ` cvs-commit at gcc dot gnu.org
                   ` (10 subsequent siblings)
  16 siblings, 0 replies; 18+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-07-21 11:17 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-12 branch has been updated by Jonathan Wakely
<redi@gcc.gnu.org>:

https://gcc.gnu.org/g:6a7ed225223bc8a13c5bbf4e77fbd7738b5b66d0

commit r12-8596-g6a7ed225223bc8a13c5bbf4e77fbd7738b5b66d0
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Wed Jul 20 12:49:28 2022 +0100

    libstdc++: Fix minor bugs in std::common_iterator

    The noexcept-specifier for some std::common_iterator constructors was
    incorrectly using an rvalue as the first argument of
    std::is_nothrow_assignable_v. This gave the wrong answer for some types,
    e.g. std::common_iterator<int*, S>, because an rvalue of scalar type
    cannot be assigned to.

    Also fix the friend declaration to use the same constraints as on the
    definition of the class template. G++ fails to diagnose this error, due
    to PR c++/96830.

    Finally, the copy constructor was using std::move for its argument
    in some cases, which should be removed.

    libstdc++-v3/ChangeLog:

            * include/bits/stl_iterator.h (common_iterator): Fix incorrect
            uses of is_nothrow_assignable_v. Fix inconsistent constraints on
            friend declaration. Do not move argument in copy constructor.
            * testsuite/24_iterators/common_iterator/1.cc: Check for
            noexcept constructibnle/assignable.

    (cherry picked from commit 3b5567c3ec7e5759bdecc6a6fc0be2b65a93636e)

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

* [Bug c++/96830] GCC does not complain about redeclaration with inconsistent requires clause
  2020-08-28  8:39 [Bug c++/96830] New: GCC does not complain template-head containing requires clause p.hyundeok76 at gmail dot com
                   ` (5 preceding siblings ...)
  2022-07-21 11:17 ` cvs-commit at gcc dot gnu.org
@ 2022-07-22  7:07 ` cvs-commit at gcc dot gnu.org
  2022-10-02  6:59 ` oschonrock at gmail dot com
                   ` (9 subsequent siblings)
  16 siblings, 0 replies; 18+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-07-22  7:07 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #6 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-11 branch has been updated by Jonathan Wakely
<redi@gcc.gnu.org>:

https://gcc.gnu.org/g:c7a7985e5e24d6d13d179006bc748f5a1eaeebfd

commit r11-10165-gc7a7985e5e24d6d13d179006bc748f5a1eaeebfd
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Wed Jul 20 12:49:28 2022 +0100

    libstdc++: Fix minor bugs in std::common_iterator

    The noexcept-specifier for some std::common_iterator constructors was
    incorrectly using an rvalue as the first argument of
    std::is_nothrow_assignable_v. This gave the wrong answer for some types,
    e.g. std::common_iterator<int*, S>, because an rvalue of scalar type
    cannot be assigned to.

    Also fix the friend declaration to use the same constraints as on the
    definition of the class template. G++ fails to diagnose this error, due
    to PR c++/96830.

    Finally, the copy constructor was using std::move for its argument
    in some cases, which should be removed.

    libstdc++-v3/ChangeLog:

            * include/bits/stl_iterator.h (common_iterator): Fix incorrect
            uses of is_nothrow_assignable_v. Fix inconsistent constraints on
            friend declaration. Do not move argument in copy constructor.
            * testsuite/24_iterators/common_iterator/1.cc: Check for
            noexcept constructibnle/assignable.

    (cherry picked from commit 3b5567c3ec7e5759bdecc6a6fc0be2b65a93636e)

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

* [Bug c++/96830] GCC does not complain about redeclaration with inconsistent requires clause
  2020-08-28  8:39 [Bug c++/96830] New: GCC does not complain template-head containing requires clause p.hyundeok76 at gmail dot com
                   ` (6 preceding siblings ...)
  2022-07-22  7:07 ` cvs-commit at gcc dot gnu.org
@ 2022-10-02  6:59 ` oschonrock at gmail dot com
  2022-10-02 18:43 ` redi at gcc dot gnu.org
                   ` (8 subsequent siblings)
  16 siblings, 0 replies; 18+ messages in thread
From: oschonrock at gmail dot com @ 2022-10-02  6:59 UTC (permalink / raw)
  To: gcc-bugs

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

Oliver Schönrock <oschonrock at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |oschonrock at gmail dot com

--- Comment #7 from Oliver Schönrock <oschonrock at gmail dot com> ---
It appears gcc's failure to "complain about redeclaration with inconsistent
requires clause " might be hiding a small bug in libstdc++:

https://godbolt.org/z/vxsY6oohM

clang-trunk reports:

/opt/compiler-explorer/gcc-snapshot/lib/gcc/x86_64-linux-gnu/13.0.0/../../../../include/c++/13.0.0/ranges:6098:14:
error: requires clause differs in template redeclaration
    requires forward_range<_Vp>
             ^
/opt/compiler-explorer/gcc-snapshot/lib/gcc/x86_64-linux-gnu/13.0.0/../../../../include/c++/13.0.0/ranges:5797:14:
note: previous template declaration is here
    requires input_range<_Vp>


whereas gcc silently swallows the inconsistency?

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

* [Bug c++/96830] GCC does not complain about redeclaration with inconsistent requires clause
  2020-08-28  8:39 [Bug c++/96830] New: GCC does not complain template-head containing requires clause p.hyundeok76 at gmail dot com
                   ` (7 preceding siblings ...)
  2022-10-02  6:59 ` oschonrock at gmail dot com
@ 2022-10-02 18:43 ` redi at gcc dot gnu.org
  2022-10-02 18:46 ` redi at gcc dot gnu.org
                   ` (7 subsequent siblings)
  16 siblings, 0 replies; 18+ messages in thread
From: redi at gcc dot gnu.org @ 2022-10-02 18:43 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #8 from Jonathan Wakely <redi at gcc dot gnu.org> ---
No, I don't think so. Libstdc++ has this for the primary template:


  template<view _Vp>
    requires input_range<_Vp>
  class chunk_view : public view_interface<chunk_view<_Vp>>
  {
    ...
    class _OuterIter;
    class _InnerIter;

And then:

  template<view _Vp>
    requires input_range<_Vp>
  class chunk_view<_Vp>::_OuterIter

and:

  template<view _Vp>
    requires input_range<_Vp>
  class chunk_view<_Vp>::_InnerIter

Then there is a partial specialization for forward_ranges:

  template<view _Vp>
    requires forward_range<_Vp>
  class chunk_view<_Vp> : public view_interface<chunk_view<_Vp>>
  {
    ...
    template<bool> class _Iterator;

and its iterator type:

  template<view _Vp>
    requires forward_range<_Vp>
  template<bool _Const>
  class chunk_view<_Vp>::_Iterator

Clang is complaining about the latter, but it's right.

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

* [Bug c++/96830] GCC does not complain about redeclaration with inconsistent requires clause
  2020-08-28  8:39 [Bug c++/96830] New: GCC does not complain template-head containing requires clause p.hyundeok76 at gmail dot com
                   ` (8 preceding siblings ...)
  2022-10-02 18:43 ` redi at gcc dot gnu.org
@ 2022-10-02 18:46 ` redi at gcc dot gnu.org
  2022-10-03 13:58 ` redi at gcc dot gnu.org
                   ` (6 subsequent siblings)
  16 siblings, 0 replies; 18+ messages in thread
From: redi at gcc dot gnu.org @ 2022-10-02 18:46 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #9 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Reduced to show Clang's confusion: https://godbolt.org/z/E1Kq4Gfed

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

* [Bug c++/96830] GCC does not complain about redeclaration with inconsistent requires clause
  2020-08-28  8:39 [Bug c++/96830] New: GCC does not complain template-head containing requires clause p.hyundeok76 at gmail dot com
                   ` (9 preceding siblings ...)
  2022-10-02 18:46 ` redi at gcc dot gnu.org
@ 2022-10-03 13:58 ` redi at gcc dot gnu.org
  2022-10-31 16:57 ` ppalka at gcc dot gnu.org
                   ` (5 subsequent siblings)
  16 siblings, 0 replies; 18+ messages in thread
From: redi at gcc dot gnu.org @ 2022-10-03 13:58 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #10 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Jonathan Wakely from comment #9)
> Reduced to show Clang's confusion: https://godbolt.org/z/E1Kq4Gfed

Reported as https://github.com/llvm/llvm-project/issues/58124

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

* [Bug c++/96830] GCC does not complain about redeclaration with inconsistent requires clause
  2020-08-28  8:39 [Bug c++/96830] New: GCC does not complain template-head containing requires clause p.hyundeok76 at gmail dot com
                   ` (10 preceding siblings ...)
  2022-10-03 13:58 ` redi at gcc dot gnu.org
@ 2022-10-31 16:57 ` ppalka at gcc dot gnu.org
  2023-03-13 20:40 ` ppalka at gcc dot gnu.org
                   ` (4 subsequent siblings)
  16 siblings, 0 replies; 18+ messages in thread
From: ppalka at gcc dot gnu.org @ 2022-10-31 16:57 UTC (permalink / raw)
  To: gcc-bugs

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

Patrick Palka <ppalka at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |h2+bugs at fsfe dot org

--- Comment #11 from Patrick Palka <ppalka at gcc dot gnu.org> ---
*** Bug 107470 has been marked as a duplicate of this bug. ***

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

* [Bug c++/96830] GCC does not complain about redeclaration with inconsistent requires clause
  2020-08-28  8:39 [Bug c++/96830] New: GCC does not complain template-head containing requires clause p.hyundeok76 at gmail dot com
                   ` (11 preceding siblings ...)
  2022-10-31 16:57 ` ppalka at gcc dot gnu.org
@ 2023-03-13 20:40 ` ppalka at gcc dot gnu.org
  2023-03-14 23:18 ` cvs-commit at gcc dot gnu.org
                   ` (3 subsequent siblings)
  16 siblings, 0 replies; 18+ messages in thread
From: ppalka at gcc dot gnu.org @ 2023-03-13 20:40 UTC (permalink / raw)
  To: gcc-bugs

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

Patrick Palka <ppalka at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |ppalka at gcc dot gnu.org
           Assignee|unassigned at gcc dot gnu.org      |ppalka at gcc dot gnu.org
             Status|NEW                         |ASSIGNED

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

* [Bug c++/96830] GCC does not complain about redeclaration with inconsistent requires clause
  2020-08-28  8:39 [Bug c++/96830] New: GCC does not complain template-head containing requires clause p.hyundeok76 at gmail dot com
                   ` (12 preceding siblings ...)
  2023-03-13 20:40 ` ppalka at gcc dot gnu.org
@ 2023-03-14 23:18 ` cvs-commit at gcc dot gnu.org
  2023-03-14 23:18 ` cvs-commit at gcc dot gnu.org
                   ` (2 subsequent siblings)
  16 siblings, 0 replies; 18+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-03-14 23:18 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #12 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Patrick Palka <ppalka@gcc.gnu.org>:

https://gcc.gnu.org/g:ec62dc95c4f8776c9f4eff2a9a06f9aef6a2d98a

commit r13-6676-gec62dc95c4f8776c9f4eff2a9a06f9aef6a2d98a
Author: Patrick Palka <ppalka@redhat.com>
Date:   Tue Mar 14 19:12:08 2023 -0400

    c++: constrained template friend class matching [PR96830]

    When instantiating a constrained template friend naming an already
    declared class template, tsubst_friend_class erroneously passes to
    redeclare_class_template the existing template's constraints instead of
    those of the friend declaration, which causes the constraint comparison
    check therein to trivially succeed and we fail to diagnose legitimate
    constraint mismatches.

            PR c++/96830

    gcc/cp/ChangeLog:

            * pt.cc (redeclare_class_template): Add missing "of" in
            constraint mismatch diagnostic.
            (tsubst_friend_class): For an already declared class template,
            substitute and pass the friend declaration's constraints to
            redeclare_class_template instead of passing the existing
            template's constraints.

    gcc/testsuite/ChangeLog:

            * g++.dg/cpp2a/concepts-friend14.C: New test.

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

* [Bug c++/96830] GCC does not complain about redeclaration with inconsistent requires clause
  2020-08-28  8:39 [Bug c++/96830] New: GCC does not complain template-head containing requires clause p.hyundeok76 at gmail dot com
                   ` (13 preceding siblings ...)
  2023-03-14 23:18 ` cvs-commit at gcc dot gnu.org
@ 2023-03-14 23:18 ` cvs-commit at gcc dot gnu.org
  2023-03-14 23:28 ` ppalka at gcc dot gnu.org
  2023-04-27 23:04 ` cvs-commit at gcc dot gnu.org
  16 siblings, 0 replies; 18+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-03-14 23:18 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #13 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Patrick Palka <ppalka@gcc.gnu.org>:

https://gcc.gnu.org/g:cd5baeb4489b6a953abbc7f02fea457fd9ed2f83

commit r13-6677-gcd5baeb4489b6a953abbc7f02fea457fd9ed2f83
Author: Patrick Palka <ppalka@redhat.com>
Date:   Tue Mar 14 19:14:29 2023 -0400

    c++: redeclaring member of constrained class template [PR96830]

    An out-of-line definition of a member of a constrained class template
    needs to repeat the template's constraints, but it turns out we don't
    verify anywhere that the two sets of constraints match.  This patch
    adds such a check to push_template_decl, nearby a similar consistency
    check for the template parameter list lengths.

            PR c++/96830

    gcc/cp/ChangeLog:

            * pt.cc (push_inline_template_parms_recursive): Set
            TEMPLATE_PARMS_CONSTRAINTS.
            (push_template_decl): For an out-of-line declaration, verify
            constraints for each enclosing template scope match those of the
            original template declaratation.

    gcc/testsuite/ChangeLog:

            * g++.dg/cpp2a/concepts-class5.C: New test.
            * g++.dg/cpp2a/concepts-class5a.C: New test.

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

* [Bug c++/96830] GCC does not complain about redeclaration with inconsistent requires clause
  2020-08-28  8:39 [Bug c++/96830] New: GCC does not complain template-head containing requires clause p.hyundeok76 at gmail dot com
                   ` (14 preceding siblings ...)
  2023-03-14 23:18 ` cvs-commit at gcc dot gnu.org
@ 2023-03-14 23:28 ` ppalka at gcc dot gnu.org
  2023-04-27 23:04 ` cvs-commit at gcc dot gnu.org
  16 siblings, 0 replies; 18+ messages in thread
From: ppalka at gcc dot gnu.org @ 2023-03-14 23:28 UTC (permalink / raw)
  To: gcc-bugs

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

Patrick Palka <ppalka at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |FIXED
   Target Milestone|---                         |13.0
             Status|ASSIGNED                    |RESOLVED

--- Comment #14 from Patrick Palka <ppalka at gcc dot gnu.org> ---
Should be fixed for GCC 13, thanks for the bug report.

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

* [Bug c++/96830] GCC does not complain about redeclaration with inconsistent requires clause
  2020-08-28  8:39 [Bug c++/96830] New: GCC does not complain template-head containing requires clause p.hyundeok76 at gmail dot com
                   ` (15 preceding siblings ...)
  2023-03-14 23:28 ` ppalka at gcc dot gnu.org
@ 2023-04-27 23:04 ` cvs-commit at gcc dot gnu.org
  16 siblings, 0 replies; 18+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-04-27 23:04 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #15 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-10 branch has been updated by Jonathan Wakely
<redi@gcc.gnu.org>:

https://gcc.gnu.org/g:3cf551240fcbc7a5e0f5ba07a9164e237e6c097b

commit r10-11316-g3cf551240fcbc7a5e0f5ba07a9164e237e6c097b
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Wed Jul 20 12:49:28 2022 +0100

    libstdc++: Fix minor bugs in std::common_iterator

    The noexcept-specifier for some std::common_iterator constructors was
    incorrectly using an rvalue as the first argument of
    std::is_nothrow_assignable_v. This gave the wrong answer for some types,
    e.g. std::common_iterator<int*, S>, because an rvalue of scalar type
    cannot be assigned to.

    Also fix the friend declaration to use the same constraints as on the
    definition of the class template. G++ fails to diagnose this error, due
    to PR c++/96830.

    Finally, the copy constructor was using std::move for its argument
    in some cases, which should be removed.

    libstdc++-v3/ChangeLog:

            * include/bits/stl_iterator.h (common_iterator): Fix incorrect
            uses of is_nothrow_assignable_v. Fix inconsistent constraints on
            friend declaration. Do not move argument in copy constructor.
            * testsuite/24_iterators/common_iterator/1.cc: Check for
            noexcept constructibnle/assignable.

    (cherry picked from commit 3b5567c3ec7e5759bdecc6a6fc0be2b65a93636e)

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

end of thread, other threads:[~2023-04-27 23:04 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-28  8:39 [Bug c++/96830] New: GCC does not complain template-head containing requires clause p.hyundeok76 at gmail dot com
2020-08-28 11:13 ` [Bug c++/96830] " redi at gcc dot gnu.org
2020-08-28 11:24 ` redi at gcc dot gnu.org
2020-08-28 11:26 ` redi at gcc dot gnu.org
2022-07-20  9:54 ` redi at gcc dot gnu.org
2022-07-20 22:59 ` [Bug c++/96830] GCC does not complain about redeclaration with inconsistent " cvs-commit at gcc dot gnu.org
2022-07-21 11:17 ` cvs-commit at gcc dot gnu.org
2022-07-22  7:07 ` cvs-commit at gcc dot gnu.org
2022-10-02  6:59 ` oschonrock at gmail dot com
2022-10-02 18:43 ` redi at gcc dot gnu.org
2022-10-02 18:46 ` redi at gcc dot gnu.org
2022-10-03 13:58 ` redi at gcc dot gnu.org
2022-10-31 16:57 ` ppalka at gcc dot gnu.org
2023-03-13 20:40 ` ppalka at gcc dot gnu.org
2023-03-14 23:18 ` cvs-commit at gcc dot gnu.org
2023-03-14 23:18 ` cvs-commit at gcc dot gnu.org
2023-03-14 23:28 ` ppalka at gcc dot gnu.org
2023-04-27 23:04 ` cvs-commit 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).