public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/97663] New: [c++17] Function with return type 'unsigned' in nested namespace misinterpreted as deduction guide
@ 2020-11-01 15:07 hans.dembinski at gmail dot com
  2020-11-01 16:54 ` [Bug c++/97663] " ville.voutilainen at gmail dot com
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: hans.dembinski at gmail dot com @ 2020-11-01 15:07 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 97663
           Summary: [c++17] Function with return type 'unsigned' in nested
                    namespace misinterpreted as deduction guide
           Product: gcc
           Version: 10.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: hans.dembinski at gmail dot com
  Target Milestone: ---

g++ with -std=c++17 since version 7.1 up to current trunk misdetects 'bar::foo'
the following code as a deduction guide for 'struct foo':

```
template <class T> struct foo {};

namespace bar {

unsigned foo();

}
```

Code on Godbolt: https://godbolt.org/z/6E4efY

Workarounds:
- Use 'unsigned int foo()'
- Use 'auto foo() -> unsigned'.

Related issue with more context:
https://github.com/boostorg/histogram/issues/290

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

* [Bug c++/97663] [c++17] Function with return type 'unsigned' in nested namespace misinterpreted as deduction guide
  2020-11-01 15:07 [Bug c++/97663] New: [c++17] Function with return type 'unsigned' in nested namespace misinterpreted as deduction guide hans.dembinski at gmail dot com
@ 2020-11-01 16:54 ` ville.voutilainen at gmail dot com
  2020-11-02 11:00 ` jakub at gcc dot gnu.org
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: ville.voutilainen at gmail dot com @ 2020-11-01 16:54 UTC (permalink / raw)
  To: gcc-bugs

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

Ville Voutilainen <ville.voutilainen at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jason at redhat dot com
             Status|UNCONFIRMED                 |NEW
     Ever confirmed|0                           |1
   Last reconfirmed|                            |2020-11-01

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

* [Bug c++/97663] [c++17] Function with return type 'unsigned' in nested namespace misinterpreted as deduction guide
  2020-11-01 15:07 [Bug c++/97663] New: [c++17] Function with return type 'unsigned' in nested namespace misinterpreted as deduction guide hans.dembinski at gmail dot com
  2020-11-01 16:54 ` [Bug c++/97663] " ville.voutilainen at gmail dot com
@ 2020-11-02 11:00 ` jakub at gcc dot gnu.org
  2020-11-02 11:40 ` jakub at gcc dot gnu.org
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: jakub at gcc dot gnu.org @ 2020-11-02 11:00 UTC (permalink / raw)
  To: gcc-bugs

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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jakub at gcc dot gnu.org

--- Comment #1 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Started with r7-6608-ga56c0ac08242269bbcc4bd1f480eda2378336776

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

* [Bug c++/97663] [c++17] Function with return type 'unsigned' in nested namespace misinterpreted as deduction guide
  2020-11-01 15:07 [Bug c++/97663] New: [c++17] Function with return type 'unsigned' in nested namespace misinterpreted as deduction guide hans.dembinski at gmail dot com
  2020-11-01 16:54 ` [Bug c++/97663] " ville.voutilainen at gmail dot com
  2020-11-02 11:00 ` jakub at gcc dot gnu.org
@ 2020-11-02 11:40 ` jakub at gcc dot gnu.org
  2020-11-03 20:43 ` cvs-commit at gcc dot gnu.org
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: jakub at gcc dot gnu.org @ 2020-11-02 11:40 UTC (permalink / raw)
  To: gcc-bugs

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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

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

--- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Created attachment 49486
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=49486&action=edit
gcc11-pr97663.patch

Only lightly tested fix (so far), passes check-c++-all without regressions.

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

* [Bug c++/97663] [c++17] Function with return type 'unsigned' in nested namespace misinterpreted as deduction guide
  2020-11-01 15:07 [Bug c++/97663] New: [c++17] Function with return type 'unsigned' in nested namespace misinterpreted as deduction guide hans.dembinski at gmail dot com
                   ` (2 preceding siblings ...)
  2020-11-02 11:40 ` jakub at gcc dot gnu.org
@ 2020-11-03 20:43 ` cvs-commit at gcc dot gnu.org
  2020-11-12 10:05 ` cvs-commit at gcc dot gnu.org
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2020-11-03 20:43 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jakub Jelinek <jakub@gcc.gnu.org>:

https://gcc.gnu.org/g:875225301e356759982573d5578ed7ca54f81f86

commit r11-4695-g875225301e356759982573d5578ed7ca54f81f86
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Tue Nov 3 21:42:51 2020 +0100

    c++: Don't try to parse a function declaration as deduction guide [PR97663]

    While these function declarations have NULL decl_specifiers->type,
    they have still type specifiers specified from which the default int
    in the return type is added, so we shouldn't try to parse those as
    deduction guides.

    2020-11-03  Jakub Jelinek  <jakub@redhat.com>

            PR c++/97663
            * parser.c (cp_parser_init_declarator): Don't try to parse
            C++17 deduction guides if there are any type specifiers even when
            type is NULL.

            * g++.dg/cpp1z/class-deduction75.C: New test.

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

* [Bug c++/97663] [c++17] Function with return type 'unsigned' in nested namespace misinterpreted as deduction guide
  2020-11-01 15:07 [Bug c++/97663] New: [c++17] Function with return type 'unsigned' in nested namespace misinterpreted as deduction guide hans.dembinski at gmail dot com
                   ` (3 preceding siblings ...)
  2020-11-03 20:43 ` cvs-commit at gcc dot gnu.org
@ 2020-11-12 10:05 ` cvs-commit at gcc dot gnu.org
  2021-04-20 23:30 ` cvs-commit at gcc dot gnu.org
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2020-11-12 10:05 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-10 branch has been updated by Jakub Jelinek
<jakub@gcc.gnu.org>:

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

commit r10-9008-gcd41e4a1864c10c7f9141284e82e5cc0a3007806
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Tue Nov 3 21:42:51 2020 +0100

    c++: Don't try to parse a function declaration as deduction guide [PR97663]

    While these function declarations have NULL decl_specifiers->type,
    they have still type specifiers specified from which the default int
    in the return type is added, so we shouldn't try to parse those as
    deduction guides.

    2020-11-03  Jakub Jelinek  <jakub@redhat.com>

            PR c++/97663
            * parser.c (cp_parser_init_declarator): Don't try to parse
            C++17 deduction guides if there are any type specifiers even when
            type is NULL.

            * g++.dg/cpp1z/class-deduction75.C: New test.

    (cherry picked from commit 875225301e356759982573d5578ed7ca54f81f86)

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

* [Bug c++/97663] [c++17] Function with return type 'unsigned' in nested namespace misinterpreted as deduction guide
  2020-11-01 15:07 [Bug c++/97663] New: [c++17] Function with return type 'unsigned' in nested namespace misinterpreted as deduction guide hans.dembinski at gmail dot com
                   ` (4 preceding siblings ...)
  2020-11-12 10:05 ` cvs-commit at gcc dot gnu.org
@ 2021-04-20 23:30 ` cvs-commit at gcc dot gnu.org
  2021-04-22 16:48 ` cvs-commit at gcc dot gnu.org
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-04-20 23:30 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-9 branch has been updated by Jakub Jelinek
<jakub@gcc.gnu.org>:

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

commit r9-9392-gc3a583316776a399fea9eb79019245138a2be181
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Tue Nov 3 21:42:51 2020 +0100

    c++: Don't try to parse a function declaration as deduction guide [PR97663]

    While these function declarations have NULL decl_specifiers->type,
    they have still type specifiers specified from which the default int
    in the return type is added, so we shouldn't try to parse those as
    deduction guides.

    2020-11-03  Jakub Jelinek  <jakub@redhat.com>

            PR c++/97663
            * parser.c (cp_parser_init_declarator): Don't try to parse
            C++17 deduction guides if there are any type specifiers even when
            type is NULL.

            * g++.dg/cpp1z/class-deduction75.C: New test.

    (cherry picked from commit cd41e4a1864c10c7f9141284e82e5cc0a3007806)

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

* [Bug c++/97663] [c++17] Function with return type 'unsigned' in nested namespace misinterpreted as deduction guide
  2020-11-01 15:07 [Bug c++/97663] New: [c++17] Function with return type 'unsigned' in nested namespace misinterpreted as deduction guide hans.dembinski at gmail dot com
                   ` (5 preceding siblings ...)
  2021-04-20 23:30 ` cvs-commit at gcc dot gnu.org
@ 2021-04-22 16:48 ` cvs-commit at gcc dot gnu.org
  2021-04-22 17:07 ` jakub at gcc dot gnu.org
  2021-09-11 14:29 ` pinskia at gcc dot gnu.org
  8 siblings, 0 replies; 10+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-04-22 16:48 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #6 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-8 branch has been updated by Jakub Jelinek
<jakub@gcc.gnu.org>:

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

commit r8-10862-ga35abb48b025291cabc364c1b335d3f675e9e97f
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Tue Nov 3 21:42:51 2020 +0100

    c++: Don't try to parse a function declaration as deduction guide [PR97663]

    While these function declarations have NULL decl_specifiers->type,
    they have still type specifiers specified from which the default int
    in the return type is added, so we shouldn't try to parse those as
    deduction guides.

    2020-11-03  Jakub Jelinek  <jakub@redhat.com>

            PR c++/97663
            * parser.c (cp_parser_init_declarator): Don't try to parse
            C++17 deduction guides if there are any type specifiers even when
            type is NULL.

            * g++.dg/cpp1z/class-deduction75.C: New test.

    (cherry picked from commit cd41e4a1864c10c7f9141284e82e5cc0a3007806)

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

* [Bug c++/97663] [c++17] Function with return type 'unsigned' in nested namespace misinterpreted as deduction guide
  2020-11-01 15:07 [Bug c++/97663] New: [c++17] Function with return type 'unsigned' in nested namespace misinterpreted as deduction guide hans.dembinski at gmail dot com
                   ` (6 preceding siblings ...)
  2021-04-22 16:48 ` cvs-commit at gcc dot gnu.org
@ 2021-04-22 17:07 ` jakub at gcc dot gnu.org
  2021-09-11 14:29 ` pinskia at gcc dot gnu.org
  8 siblings, 0 replies; 10+ messages in thread
From: jakub at gcc dot gnu.org @ 2021-04-22 17:07 UTC (permalink / raw)
  To: gcc-bugs

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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|---                         |FIXED

--- Comment #7 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Fixed.

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

* [Bug c++/97663] [c++17] Function with return type 'unsigned' in nested namespace misinterpreted as deduction guide
  2020-11-01 15:07 [Bug c++/97663] New: [c++17] Function with return type 'unsigned' in nested namespace misinterpreted as deduction guide hans.dembinski at gmail dot com
                   ` (7 preceding siblings ...)
  2021-04-22 17:07 ` jakub at gcc dot gnu.org
@ 2021-09-11 14:29 ` pinskia at gcc dot gnu.org
  8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-09-11 14:29 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |8.5

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

end of thread, other threads:[~2021-09-11 14:29 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-01 15:07 [Bug c++/97663] New: [c++17] Function with return type 'unsigned' in nested namespace misinterpreted as deduction guide hans.dembinski at gmail dot com
2020-11-01 16:54 ` [Bug c++/97663] " ville.voutilainen at gmail dot com
2020-11-02 11:00 ` jakub at gcc dot gnu.org
2020-11-02 11:40 ` jakub at gcc dot gnu.org
2020-11-03 20:43 ` cvs-commit at gcc dot gnu.org
2020-11-12 10:05 ` cvs-commit at gcc dot gnu.org
2021-04-20 23:30 ` cvs-commit at gcc dot gnu.org
2021-04-22 16:48 ` cvs-commit at gcc dot gnu.org
2021-04-22 17:07 ` jakub at gcc dot gnu.org
2021-09-11 14:29 ` 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).