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

            Bug ID: 85515
           Summary: Bogus suggestions from "GCC's leaky abstractions"
           Product: gcc
           Version: 8.0
            Status: UNCONFIRMED
          Keywords: diagnostic
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: dmalcolm at gcc dot gnu.org
  Target Milestone: ---

Jason Turner's video C++ Weekly - Ep 112 - GCC's Leaky Abstractions
  https://www.youtube.com/watch?v=S9_mYmvO4Ow

shows two issues where g++ offers suggestions about implementation details:

Example 1:

int main ()
{
  auto lambda = [val = 2](){};

  lambda.val;
}

<source>: In function 'int main()':
<source>:5:10: error: 'struct main()::<lambda()>' has no member named 'val';
did you mean '__val'?
   lambda.val;
          ^~~
          __val

Compiler returned: 1


Example 2:

void test ()
{
  int arr[] = {1, 2, 3, 4, 5};
  for (const auto v: arr) {
    _forbegin
  }
}

<source>: In function 'void test()':
<source>:5:5: error: '_forbegin' was not declared in this scope
     _forbegin
     ^~~~~~~~~
<source>:5:5: note: suggested alternative: '__for_begin'
     _forbegin
     ^~~~~~~~~
     __for_begin

Compiler returned: 1

In the video, he uses these suggestions to get a glimpse behind the
abstraction.

We shouldn't offer these suggestions; one way would be to exclude fieldnames
that begin with two underscores.

Reply via email to