public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/102338] New: Recursive noexcept specification inside class/struct
@ 2021-09-15  7:19 jergussuja at gmail dot com
  2021-09-15  7:21 ` [Bug c++/102338] " jergussuja at gmail dot com
                   ` (12 more replies)
  0 siblings, 13 replies; 14+ messages in thread
From: jergussuja at gmail dot com @ 2021-09-15  7:19 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 102338
           Summary: Recursive noexcept specification inside class/struct
           Product: gcc
           Version: 8.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: jergussuja at gmail dot com
  Target Milestone: ---

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

* [Bug c++/102338] Recursive noexcept specification inside class/struct
  2021-09-15  7:19 [Bug c++/102338] New: Recursive noexcept specification inside class/struct jergussuja at gmail dot com
@ 2021-09-15  7:21 ` jergussuja at gmail dot com
  2021-09-15  7:22 ` jergussuja at gmail dot com
                   ` (11 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: jergussuja at gmail dot com @ 2021-09-15  7:21 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Jerguš Suja <jergussuja at gmail dot com> ---
Created attachment 51463
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=51463&action=edit
preprocessed file

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

* [Bug c++/102338] Recursive noexcept specification inside class/struct
  2021-09-15  7:19 [Bug c++/102338] New: Recursive noexcept specification inside class/struct jergussuja at gmail dot com
  2021-09-15  7:21 ` [Bug c++/102338] " jergussuja at gmail dot com
@ 2021-09-15  7:22 ` jergussuja at gmail dot com
  2021-09-15  7:23 ` jergussuja at gmail dot com
                   ` (10 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: jergussuja at gmail dot com @ 2021-09-15  7:22 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Jerguš Suja <jergussuja at gmail dot com> ---
Created attachment 51464
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=51464&action=edit
preprocessed file

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

* [Bug c++/102338] Recursive noexcept specification inside class/struct
  2021-09-15  7:19 [Bug c++/102338] New: Recursive noexcept specification inside class/struct jergussuja at gmail dot com
  2021-09-15  7:21 ` [Bug c++/102338] " jergussuja at gmail dot com
  2021-09-15  7:22 ` jergussuja at gmail dot com
@ 2021-09-15  7:23 ` jergussuja at gmail dot com
  2021-09-15  7:28 ` jergussuja at gmail dot com
                   ` (9 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: jergussuja at gmail dot com @ 2021-09-15  7:23 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Jerguš Suja <jergussuja at gmail dot com> ---
Created attachment 51465
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=51465&action=edit
minimal testcase code snippet

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

* [Bug c++/102338] Recursive noexcept specification inside class/struct
  2021-09-15  7:19 [Bug c++/102338] New: Recursive noexcept specification inside class/struct jergussuja at gmail dot com
                   ` (2 preceding siblings ...)
  2021-09-15  7:23 ` jergussuja at gmail dot com
@ 2021-09-15  7:28 ` jergussuja at gmail dot com
  2021-09-15  7:46 ` pinskia at gcc dot gnu.org
                   ` (8 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: jergussuja at gmail dot com @ 2021-09-15  7:28 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Jerguš Suja <jergussuja at gmail dot com> ---
gcc version 9.3.0

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

Code that trigger compilation failed:

struct S {

    template<typename T>
    static auto f(T && t) noexcept {
        return true;
    }

    template<typename T, typename... Ts>
    static auto f(T && t, Ts && ... ts) noexcept(noexcept(f(ts...))) {
        return f(ts...);
    }

};

int main() {
    S::f(true, 0, 5u);
    return 0;
}

Compiler error:

bug.cpp: In instantiation of ‘static auto S::f(T&&, Ts&& ...) [with T = bool;
Ts = {int, unsigned int}]’:
bug.cpp:16:21:   required from here
bug.cpp:9:60: error: no matching function for call to ‘S::f(int&, unsigned
int&)’
    9 |     static auto f(T && t, Ts && ... ts) noexcept(noexcept(f(ts...))) {
      |                                                           ~^~~~~~~
bug.cpp:4:17: note: candidate: ‘template<class T> static auto S::f(T&&)’
    4 |     static auto f(T && t) noexcept {
      |                 ^
bug.cpp:4:17: note:   template argument deduction/substitution failed:
bug.cpp:9:60: note:   candidate expects 1 argument, 2 provided
    9 |     static auto f(T && t, Ts && ... ts) noexcept(noexcept(f(ts...))) {
      |                                                           ~^~~~~~~

GCC version 7.5 compile this, but version 8 and more does not. If I declare
function 'f' in scope of class or struct, it should be visible everywhere
inside class/struct scope. Also in noexcept specifier (it should not matter if
it is recursive call). MSVC v19.28 and Clang 12.0.1 accept this and compile
this code.

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

* [Bug c++/102338] Recursive noexcept specification inside class/struct
  2021-09-15  7:19 [Bug c++/102338] New: Recursive noexcept specification inside class/struct jergussuja at gmail dot com
                   ` (3 preceding siblings ...)
  2021-09-15  7:28 ` jergussuja at gmail dot com
@ 2021-09-15  7:46 ` pinskia at gcc dot gnu.org
  2021-09-15  7:47 ` pinskia at gcc dot gnu.org
                   ` (7 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-09-15  7:46 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
here is a more reduced testcase:
struct S {
    template<typename T>
     int f(T && t) noexcept {
        return 0;
    }
    template<typename T, typename... Ts>
     int f(T && t, Ts && ... ts) noexcept(noexcept(f(ts...))) {
        return f(ts...);
    }
};

bool t =  S{}.f(true, 0, 5u);

If this was not a struct, the code would be invalid as the recusive f is not
found.

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

* [Bug c++/102338] Recursive noexcept specification inside class/struct
  2021-09-15  7:19 [Bug c++/102338] New: Recursive noexcept specification inside class/struct jergussuja at gmail dot com
                   ` (4 preceding siblings ...)
  2021-09-15  7:46 ` pinskia at gcc dot gnu.org
@ 2021-09-15  7:47 ` pinskia at gcc dot gnu.org
  2021-09-15  7:50 ` pinskia at gcc dot gnu.org
                   ` (6 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-09-15  7:47 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #6 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Andrew Pinski from comment #5)
> here is a more reduced testcase:
> struct S {
>     template<typename T>
>      int f(T && t) noexcept {
>         return 0;
>     }
>     template<typename T, typename... Ts>
>      int f(T && t, Ts && ... ts) noexcept(noexcept(f(ts...))) {
>         return f(ts...);
>     }
> };
> 
> bool t =  S{}.f(true, 0, 5u);
> 
> If this was not a struct, the code would be invalid as the recusive f is not
> found.

Oh the non-static case never compiled either.

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

* [Bug c++/102338] Recursive noexcept specification inside class/struct
  2021-09-15  7:19 [Bug c++/102338] New: Recursive noexcept specification inside class/struct jergussuja at gmail dot com
                   ` (5 preceding siblings ...)
  2021-09-15  7:47 ` pinskia at gcc dot gnu.org
@ 2021-09-15  7:50 ` pinskia at gcc dot gnu.org
  2021-09-15  8:04 ` [Bug c++/102338] [9/10/11/12 Regression] " rguenth at gcc dot gnu.org
                   ` (5 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-09-15  7:50 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #7 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Note clang is borken in a different way, take:
struct S {
    template<typename T>
     int f(T && t) noexcept {
        return 0;
    }
    template<typename T, typename... Ts>
    static int f(T && t, Ts && ... ts) noexcept(noexcept(f(ts...))) {
        return f(ts...);
    }
};

//int t =  S{}.f(true, 0, 5u);
bool t1 =  noexcept(S{}.f(true, 0, 5u));

Definitely should not compile.

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

* [Bug c++/102338] [9/10/11/12 Regression] Recursive noexcept specification inside class/struct
  2021-09-15  7:19 [Bug c++/102338] New: Recursive noexcept specification inside class/struct jergussuja at gmail dot com
                   ` (6 preceding siblings ...)
  2021-09-15  7:50 ` pinskia at gcc dot gnu.org
@ 2021-09-15  8:04 ` rguenth at gcc dot gnu.org
  2022-01-20 19:09 ` ppalka at gcc dot gnu.org
                   ` (4 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: rguenth at gcc dot gnu.org @ 2021-09-15  8:04 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |rejects-valid
      Known to work|                            |7.5.0
      Known to fail|                            |8.1.0
   Target Milestone|---                         |9.5
            Summary|Recursive noexcept          |[9/10/11/12 Regression]
                   |specification inside        |Recursive noexcept
                   |class/struct                |specification inside
                   |                            |class/struct

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

* [Bug c++/102338] [9/10/11/12 Regression] Recursive noexcept specification inside class/struct
  2021-09-15  7:19 [Bug c++/102338] New: Recursive noexcept specification inside class/struct jergussuja at gmail dot com
                   ` (7 preceding siblings ...)
  2021-09-15  8:04 ` [Bug c++/102338] [9/10/11/12 Regression] " rguenth at gcc dot gnu.org
@ 2022-01-20 19:09 ` ppalka at gcc dot gnu.org
  2022-01-20 19:29 ` mpolacek at gcc dot gnu.org
                   ` (3 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: ppalka at gcc dot gnu.org @ 2022-01-20 19:09 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |mpolacek at gcc dot gnu.org,
                   |                            |ppalka at gcc dot gnu.org
     Ever confirmed|0                           |1
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2022-01-20

--- Comment #8 from Patrick Palka <ppalka at gcc dot gnu.org> ---
This appears to be fixed on trunk by r12-6025.

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

* [Bug c++/102338] [9/10/11/12 Regression] Recursive noexcept specification inside class/struct
  2021-09-15  7:19 [Bug c++/102338] New: Recursive noexcept specification inside class/struct jergussuja at gmail dot com
                   ` (8 preceding siblings ...)
  2022-01-20 19:09 ` ppalka at gcc dot gnu.org
@ 2022-01-20 19:29 ` mpolacek at gcc dot gnu.org
  2022-01-20 20:03 ` cvs-commit at gcc dot gnu.org
                   ` (2 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2022-01-20 19:29 UTC (permalink / raw)
  To: gcc-bugs

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

Marek Polacek <mpolacek at gcc dot gnu.org> changed:

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

--- Comment #9 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Thanks Patrick.  I'll check the tests here and potentially add them into our
testsuite.

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

* [Bug c++/102338] [9/10/11/12 Regression] Recursive noexcept specification inside class/struct
  2021-09-15  7:19 [Bug c++/102338] New: Recursive noexcept specification inside class/struct jergussuja at gmail dot com
                   ` (9 preceding siblings ...)
  2022-01-20 19:29 ` mpolacek at gcc dot gnu.org
@ 2022-01-20 20:03 ` cvs-commit at gcc dot gnu.org
  2022-01-20 20:06 ` [Bug c++/102338] [9/10/11 " mpolacek at gcc dot gnu.org
  2022-01-21  1:55 ` pinskia at gcc dot gnu.org
  12 siblings, 0 replies; 14+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-01-20 20:03 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #10 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The trunk branch has been updated by Marek Polacek <mpolacek@gcc.gnu.org>:

https://gcc.gnu.org/g:30b38394b482ce894d9bc81731a0eea8711f4587

commit r12-6778-g30b38394b482ce894d9bc81731a0eea8711f4587
Author: Marek Polacek <polacek@redhat.com>
Date:   Thu Jan 20 15:00:11 2022 -0500

    c++: Add test for fixed PR [PR102338]

    This was fixed by r12-6025 and is sufficiently different from
    noexcept71.C that I think we should add it.

            PR c++/102338

    gcc/testsuite/ChangeLog:

            * g++.dg/cpp1y/noexcept2.C: New test.

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

* [Bug c++/102338] [9/10/11 Regression] Recursive noexcept specification inside class/struct
  2021-09-15  7:19 [Bug c++/102338] New: Recursive noexcept specification inside class/struct jergussuja at gmail dot com
                   ` (10 preceding siblings ...)
  2022-01-20 20:03 ` cvs-commit at gcc dot gnu.org
@ 2022-01-20 20:06 ` mpolacek at gcc dot gnu.org
  2022-01-21  1:55 ` pinskia at gcc dot gnu.org
  12 siblings, 0 replies; 14+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2022-01-20 20:06 UTC (permalink / raw)
  To: gcc-bugs

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

Marek Polacek <mpolacek at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|[9/10/11/12 Regression]     |[9/10/11 Regression]
                   |Recursive noexcept          |Recursive noexcept
                   |specification inside        |specification inside
                   |class/struct                |class/struct
             Status|ASSIGNED                    |RESOLVED
         Resolution|---                         |FIXED

--- Comment #11 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Fixed in GCC 12.  I could be convinced to backport r12-6025 to 11 though.

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

* [Bug c++/102338] [9/10/11 Regression] Recursive noexcept specification inside class/struct
  2021-09-15  7:19 [Bug c++/102338] New: Recursive noexcept specification inside class/struct jergussuja at gmail dot com
                   ` (11 preceding siblings ...)
  2022-01-20 20:06 ` [Bug c++/102338] [9/10/11 " mpolacek at gcc dot gnu.org
@ 2022-01-21  1:55 ` pinskia at gcc dot gnu.org
  12 siblings, 0 replies; 14+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-01-21  1:55 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|9.5                         |12.0

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

end of thread, other threads:[~2022-01-21  1:55 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-15  7:19 [Bug c++/102338] New: Recursive noexcept specification inside class/struct jergussuja at gmail dot com
2021-09-15  7:21 ` [Bug c++/102338] " jergussuja at gmail dot com
2021-09-15  7:22 ` jergussuja at gmail dot com
2021-09-15  7:23 ` jergussuja at gmail dot com
2021-09-15  7:28 ` jergussuja at gmail dot com
2021-09-15  7:46 ` pinskia at gcc dot gnu.org
2021-09-15  7:47 ` pinskia at gcc dot gnu.org
2021-09-15  7:50 ` pinskia at gcc dot gnu.org
2021-09-15  8:04 ` [Bug c++/102338] [9/10/11/12 Regression] " rguenth at gcc dot gnu.org
2022-01-20 19:09 ` ppalka at gcc dot gnu.org
2022-01-20 19:29 ` mpolacek at gcc dot gnu.org
2022-01-20 20:03 ` cvs-commit at gcc dot gnu.org
2022-01-20 20:06 ` [Bug c++/102338] [9/10/11 " mpolacek at gcc dot gnu.org
2022-01-21  1:55 ` 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).