Author Topic: C++ local variable tagging in constructors with brace initalizers  (Read 716 times)

Dennis

  • Senior Community Member
  • Posts: 3965
  • Hero Points: 517
Looks like C++ local variable tagging breaks in constructors using a brace initializer expression:
Code: [Select]
struct Contents {
  double stuff;
  double mint;
};

class Oreo {
  Oreo();
private:
    Contents mFilling;
};

Oreo::Oreo() :
  mFilling{1.0, 2.0}
{
  auto home = getenv("HOME");
  if (home && *home) {        // <-- Can't find home
    mFilling.stuff = 2.0;
  }
}

Clark

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 6877
  • Hero Points: 530
Re: C++ local variable tagging in constructors with brace initalizers
« Reply #1 on: March 13, 2024, 09:27:51 PM »
Reproduced. We will look into this.

Clark

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 6877
  • Hero Points: 530
Re: C++ local variable tagging in constructors with brace initalizers
« Reply #2 on: March 14, 2024, 01:28:33 AM »
Fixed for 28.0.2

Dennis

  • Senior Community Member
  • Posts: 3965
  • Hero Points: 517
Re: C++ local variable tagging in constructors with brace initalizers
« Reply #3 on: March 14, 2024, 01:37:48 PM »
Added detail, this also is an issue if the brace initializer is parenthesized:
Code: [Select]
Oreo::Oreo() :
  mFilling( {1.0, 2.0} )
{
  auto home = getenv("HOME");
  if (home && *home) {        // <-- Can't find home
    mFilling.stuff = 2.0;
  }
}

Clark

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 6877
  • Hero Points: 530
Re: C++ local variable tagging in constructors with brace initalizers
« Reply #4 on: March 14, 2024, 02:03:23 PM »
The 28.0.2 fix works for this too. The fix was to identify a constructor initializer list and parse it like we do in other parts of the code.