This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/82373] New: syntax error in error message


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

            Bug ID: 82373
           Summary: syntax error in error message
           Product: gcc
           Version: 7.2.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: drepper.fsp+rhbz at gmail dot com
  Target Milestone: ---

Compiling the invalid code at the bottom produces the following message:

y.cc: In function ‘auto bar::foo(int))(int)’:
y.cc:7:12: error: inconsistent deduction for auto return type: ‘int (*)(int)’
and then ‘std::nullptr_t’
     return nullptr;
            ^~~~~~~

The function name is wrong.  The parameter list of the inferred return type
should not be printed.

   auto bar::foo(int)

The correct form would have (* before the function name:

   auto (*bar::foo(int))(int)
        ^^

But then the 'auto' must be replaced as well.  But this is wrong since it does
not correspond to a function in the source.



namespace bar {
  int(*fp)(int);
  auto foo(int a)
  {
    if (a)
      return fp;
    return nullptr;
  }
}

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]