Bug 78770 - error: 'bar' was not declared in this scope. note: suggested alternative: 'bar'
Summary: error: 'bar' was not declared in this scope. note: suggested alternative: 'bar'
Status: RESOLVED DUPLICATE of bug 72786
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 7.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-12-11 12:29 UTC by Askar Safin
Modified: 2016-12-12 09:47 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Askar Safin 2016-12-11 12:29:19 UTC
Consider this code:

struct foo
{
  friend void
  bar (void);

  void baz (void)
  {
    bar ();
  }
};

void
bar (void)
{
}

g++ gives very strange "suggestion":

gcrash.cpp: In member function 'void foo::baz()':
gcrash.cpp:8:5: error: 'bar' was not declared in this scope
     bar ();
     ^~~
gcrash.cpp:8:5: note: suggested alternative: 'bar'
     bar ();
     ^~~
     bar

Error seems to be legit. Problem is in suggestion. g++ suggests to replace "bar" with "bar". (???)

Command line:
/usr/lib/gcc-snapshot/bin/g++ -std=c++1z -fdiagnostics-color=always -c -o /dev/null gcrash.cpp

debian gnu/linux stretch amd64 (x86_64). debian package gcc-snapshot 20161124-2. gcc -v:

Using built-in specs.
COLLECT_GCC=/usr/lib/gcc-snapshot/bin/gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc-snapshot/libexec/gcc/x86_64-linux-gnu/7.0.0/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Debian 20161124-2' --with-bugurl=file:///usr/share/doc/gcc-snapshot/README.Bugs --enable-languages=c,ada,c++,go,fortran,objc,obj-c++ --prefix=/usr/lib/gcc-snapshot --program-prefix= --enable-shared --enable-linker-build-id --disable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-libmpx --enable-plugin --with-system-zlib --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-checking=yes --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 7.0.0 20161124 (experimental) [trunk revision 242836] (Debian 20161124-2)
Comment 1 Martin Liška 2016-12-12 09:47:18 UTC
Fixed by r242965, I'm marking that as duplicate of one of PRs fixed by the commit.

*** This bug has been marked as a duplicate of bug 72786 ***