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

            Bug ID: 116446
           Summary: GCC incorrectly accepts multiple method declarations
                    with deduced return types
           Product: gcc
           Version: 14.2.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: iamkirkezz at gmail dot com
  Target Milestone: ---

Created attachment 58968
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=58968&action=edit
output of `g++ main.cpp -v`

| gcc version: 14.2.1 20240805
| system type: x86_64-pc-linux-gnu
| gcc options and output: see an attachment
GCC accepts the following source code (https://godbolt.org/z/f8q61xje9):
```
struct S {
    auto getA(), getB();
};

int main() {}

auto S::getA() { return 42; }
auto S::getB() { return 'c'; }
```
while clang errors out:
> error: function with deduced return type must be the only declaration in its 
> group

Similar code in the global scope (https://godbolt.org/z/r5Whnbsn4):
```
auto getA(), getB();

int main() {}

auto getA() { return 42; }
auto getB() { return 'c'; }
```
is rejected by both compilers, GCC errors out:
> error: non-variable 'auto getB()' in declaration with more than one 
> declarator with placeholder type

Reply via email to