Author Topic: 3 issues with "auto" keyword in C++ and auto-list feature in 23.0.1.2  (Read 588 times)

rowbearto

  • Senior Community Member
  • Posts: 1344
  • Hero Points: 100
I found 3 issues with "auto" keyword in C++ and auto-list feature in 23.0.1.2 using Visual Studio 2015 on Windows 7 x64. The issues reproduce with a clean config.

I DON'T have this issue in my Linux x64 with CentOS 7.2 and gcc 4.8.2, only with Visual Studio 2015/Windows x64.

I DO have this issue using a compiler tag file with cygwin gcc (directory C:\cygwin\lib\gcc\i686-pc-cygwin\7.3.0\include) instead of Visual Studio 2015.

I have attached a full Visual Studio 2015 solution.

Below is the code, search for "ISSUE" below to see where the 3 issues are.

Code: [Select]
#include <map>
#include <string>
#include <iostream>

class MyClass
{
public:
  MyClass(int item1, int item2)
    : item1_(item1),
      item2_(item2)
  {
  }
  int item1_;
  int item2_;
};

int main(int argc, char* argv[])
{
  // Tools->Tag files shows my tag file for Visual Studio 14.0 is selected and includes many files in the VC\include directory

  // push-tag on std::map properly finds it in C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\map
  // push-tag on std::string properly finds it in C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\xstring
  // push-tag on MyClass properly finds it in this file
  std::map<std::string, MyClass> myClassMap_;
  std::string myString = "hi there";
  myClassMap_.try_emplace(myString, 1, 2);

  // myMapIt case 1: Use auto
  auto myMapIt = myClassMap_.lower_bound(myString);
  // myMapIt case 2: Declare the type
  //std::map<std::string, MyClass>::iterator myMapIt = myClassMap_.lower_bound(myString);

  // ISSUE #1:
  // When I place the cursor to the right of the '>' in myMapIt->first, SE freezes for a second or 2
  // After it unfreezes, if I use the scroll wheel to scroll, SE is also slow
  //
  // ISSUE #2:
  // When I backspace the '>' below and type > again for autolist, I get no autolist showing "first" and "second"
  // This happens for both "myMapIt case 1: Use auto" and for "myMapIt case 2: Declare the type"
  auto itemKey = myMapIt->first;
  auto itemValue = myMapIt->second;
  std::cout << "itemKey: " << itemKey << "\n";

  // ISSUE #3: When I type the "." after "itemValue" below, I don't get an autolist for "item1_" and "item2_"
  std::cout << "itemValue.item1_: " << itemValue.item1_ << "\n";
}
« Last Edit: March 03, 2019, 05:42:45 pm by rowbearto »

rowbearto

  • Senior Community Member
  • Posts: 1344
  • Hero Points: 100
Re: 3 issues with "auto" keyword in C++ and auto-list feature in 23.0.1.2
« Reply #1 on: March 07, 2019, 04:47:24 pm »
Hi Dennis: Were you able to reproduce this issue?

Dennis

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 2633
  • Hero Points: 406
Re: 3 issues with "auto" keyword in C++ and auto-list feature in 23.0.1.2
« Reply #2 on: March 07, 2019, 06:56:18 pm »
It is on my list.

Dennis

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 2633
  • Hero Points: 406
Re: 3 issues with "auto" keyword in C++ and auto-list feature in 23.0.1.2
« Reply #3 on: March 13, 2019, 03:24:03 pm »
Just thought I would give an update on this.  I have reproduced the problem and have been working on a fix.  The latest version of the STL sets a new standard for nasty and ugly code.  I'm working around some things which our template engine can not currently handle, specifically the rampant use of partial specialization, and their complete abandonment of separation of API and implementation.  For a future major release, I am planning on rewriting the template engine to handle partial specialization directly.

rowbearto

  • Senior Community Member
  • Posts: 1344
  • Hero Points: 100
Re: 3 issues with "auto" keyword in C++ and auto-list feature in 23.0.1.2
« Reply #4 on: March 13, 2019, 03:25:31 pm »
Thanks Dennis!

Dennis

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 2633
  • Hero Points: 406
Re: 3 issues with "auto" keyword in C++ and auto-list feature in 23.0.1.2
« Reply #5 on: March 13, 2019, 10:53:03 pm »
There will be some improvements in this department in the next hot fix for 23.0.1.

There are some caveats:

  1) It won't handle every conceivable test case for the STL.  I fixed this std::map<> issue and put in a lot of general improvements, so it should help other STL containers, but with the level of ugly we are dealing with here, no one on this planet could guarantee it to work everywhere.

  2) This type resolution is difficult, no two ways about it.  Take a week off work sometime and trace through it, I mean, really trace through it, don't take any shortcuts thinking something like "iterator" or "pointer" evaluates to the obvious type you would expect it to.  It doesn't -- it never does -- it just goes from obscure to more obscure to inane then circles back.  The long and short of it is that these aren't the cases where you can expect auto-list members to be instant.  You may need to increase Tools > Options > Editing > Context Tagging > Auto-Complete performance tuning > "Timeout after (ms) when automatic" if you want "." and "->" to have enough time to work through this web of insanity.  Otherwise, plan on hitting "Alt+Dot" to force list-members to finish.

<soapbox>
Folks who read this might thing that my critical comments with respect to the STL and Boost indicate a lack of support for them and C++ in general.  The facts couldn't be more the opposite.  C++ remains my favorite language -- I just hold the opinion that the powers behind the STL have lost thier way -- I feel this way whenever I see code where the interface and the implementation have no separation.  I understand what they are trying to do with respect to performance and memory footprint, but I hope they find a better way to do it in the future, because this stuff is nuts.
</soapbox>

rowbearto

  • Senior Community Member
  • Posts: 1344
  • Hero Points: 100
Re: 3 issues with "auto" keyword in C++ and auto-list feature in 23.0.1.2
« Reply #6 on: March 14, 2019, 01:50:23 pm »
Thank you Dennis for fighting the good fight! I have also looked around in the STL headers and it is a nightmare. I sometimes think it is better to not use auto due to easier to read, looks like not just for humans to read and also for SlickEdit to read!

Was wondering which versions of STL you tested against? When I first reported the issue I saw it with Visual Studio 2015. But then later I saw it will gcc 7.3.0 (under cygwin). Did you test against these 2? Any others like clang?

Dennis

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 2633
  • Hero Points: 406
Re: 3 issues with "auto" keyword in C++ and auto-list feature in 23.0.1.2
« Reply #7 on: March 14, 2019, 02:20:24 pm »
Latest Clang on macOS (libc++)
Visual Studio 2015, 2017, 2010, 2008
GCC 7.1 (mingw)

I'm not advocating avoiding "auto".  It's one of the good things about C++.

rowbearto

  • Senior Community Member
  • Posts: 1344
  • Hero Points: 100
Re: 3 issues with "auto" keyword in C++ and auto-list feature in 23.0.1.2
« Reply #8 on: March 14, 2019, 02:25:07 pm »
Thanks. I'd like to use auto too, it just comes with a tradeoff of being harder to read, harder for tools to figure out. I'd like SlickEdit to be able to handle it, but in cases where it can't figure it out, or autolist takes too long I suppose putting in the type explicitly can help.

rowbearto

  • Senior Community Member
  • Posts: 1344
  • Hero Points: 100
Re: 3 issues with "auto" keyword in C++ and auto-list feature in 23.0.1.2
« Reply #9 on: March 27, 2019, 11:51:43 pm »
Dennis: I tried the latest hotfix but the autolist still doesn't work for me. I'm using Visual Studio 2015.

Dennis

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 2633
  • Hero Points: 406
Re: 3 issues with "auto" keyword in C++ and auto-list feature in 23.0.1.2
« Reply #10 on: March 28, 2019, 02:21:13 pm »
You may need to rebuild your Visual Studio 2015 C/C++ Compiler tag file.

That might solve it, except there is one thing in there that might be a problem, a template union class (std::__value_type), which is a C++1x thing that our parser did not handle in 23.0.1, that fix will have to go into the next release, it can't be hot fixed.  Without digging into it, I do not recall for certain if the Visual Studio headers use this same construct or not, so maybe rebuilding the tag file will do the trick.

rowbearto

  • Senior Community Member
  • Posts: 1344
  • Hero Points: 100
Re: 3 issues with "auto" keyword in C++ and auto-list feature in 23.0.1.2
« Reply #11 on: March 28, 2019, 02:48:35 pm »
I did try rebuilding the tag file and the autolist didn't happen.

Dennis

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 2633
  • Hero Points: 406
Re: 3 issues with "auto" keyword in C++ and auto-list feature in 23.0.1.2
« Reply #12 on: March 28, 2019, 04:36:57 pm »
Did you remember to uncheck "Retag modified files only" ?

rowbearto

  • Senior Community Member
  • Posts: 1344
  • Hero Points: 100
Re: 3 issues with "auto" keyword in C++ and auto-list feature in 23.0.1.2
« Reply #13 on: March 28, 2019, 04:49:04 pm »
Yes I did uncheck "Retag modified only" and repeated it a few times. This was with Visual Studio 2015. And I also made sure it was my default compiler.

Dennis

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 2633
  • Hero Points: 406
Re: 3 issues with "auto" keyword in C++ and auto-list feature in 23.0.1.2
« Reply #14 on: March 28, 2019, 10:06:10 pm »
Reproduced again.  I'll take another look at it on Windows with Visual Studio 2015.  I had it working then had to make more tweaks for macos/clang, but didn't expect those changes to break anything elsewhere.  Could go back and forth forever here, the STL is so fragile.