Author Topic: Edge case c++ auto keyword and list-symbols  (Read 245 times)

mrothman

  • Senior Community Member
  • Posts: 114
  • Hero Points: 1
Edge case c++ auto keyword and list-symbols
« on: November 20, 2017, 10:31:00 pm »
Using v21.0.3.0, Linux, latest hotfix applied.  I searched around and found some simpler issues with auto keyword and list-symbols (or auto-complete as it is sometimes called), but they have been fixed.  Here's mine:
auto foo = std::make_shared<std::vector<myType>>();

Now type foo-> and hope for list-symbols drop down, but no luck, says "Attempt to use operator -> but variable 'foo' is not a pointer'.

At first I said, well hey this is hard because even without the auto, SlickEdit would have to understand the semantics of shared_ptr and I didn't expect it to.  But it does! Because if I switch to:
std::shared_ptr<std::vector<myType>> foo = std::make_shared<std::vector<myType>>
Then it works.  (Figuring out the symbol list takes significantly longer than usual, but it does work).

I suspect this is a hard problem - you'd need compiler level analysis going on to determine the type that auto refers to.  But I thought I'd just check whether I'd missed some bit I can flip to fix this.

Dennis

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 2252
  • Hero Points: 283
Re: Edge case c++ auto keyword and list-symbols
« Reply #1 on: November 22, 2017, 12:47:25 am »
I'll take a look at this one.  What version of GCC are you working with?

mrothman

  • Senior Community Member
  • Posts: 114
  • Hero Points: 1
Re: Edge case c++ auto keyword and list-symbols
« Reply #2 on: November 22, 2017, 01:23:51 pm »
Hi Dennis.  So interesting question.  We build with a makefile which among other things points onto our network at in whatever version of gcc our systems team has validated our code base against.  That happens to be 6.3.0 at the moment.  BUT I doubt that this would be visible at all to SlickEdit (since we build with our Makefile). So I suspect that what you are asking is what version is SlickEdit using to analyze the code?  I hadn't explicitly set that, since I didn't know it was even a factor.  It looks like it happens to be 4.72 (ouch, that wouldn't even have c++11 !).  I probably can download and put any version of gcc in place for SlickEdit that you would recommend, since it would have no effect on our build.  Meanwhile I'll try whatever latest version we have around here and see if that makes a difference.

mrothman

  • Senior Community Member
  • Posts: 114
  • Hero Points: 1
Re: Edge case c++ auto keyword and list-symbols
« Reply #3 on: November 22, 2017, 02:41:56 pm »
More info: I changed the following:
1) Under C/C++ Compiler properties in the Options section, I created a gcc 6.3 Name and configuration and pointed it at the compiler include directories for 6.3.0.  Not quite sure what the "Header File" option is.  I deleted the rest of my Compiler Configurations since they were hopelessly old.  I deleted the tag file(s) for those older include directories also.
2) Under the "Build" menu, I specified the Compiler by putting in the entire path to the executable for gcc 6.3.0
3) In the Project Properties dialog, I specified under the "Compiler/Link" tab the gcc 6.3.0 configuration (which is now the only one I have).

I closed SlickEdit, saving config and then re-opened.  I still get the same error message when trying to list symbols for the variable whose type was specified as "auto".  Let me know if a) I need a later gcc and b) there are other places in the configuration I need to touch.  Thanks.

mrothman

  • Senior Community Member
  • Posts: 114
  • Hero Points: 1
Re: Edge case c++ auto keyword and list-symbols
« Reply #4 on: November 22, 2017, 03:20:58 pm »
And one more piece of info: if I change the -> to a ".", the correct attributes for an std::shared_ptr are listed, so it does know that my variable is a shared_ptr, it just doesn't seem to be able to deal with the -> operator on it.  For fun I tried:
auto foo = std::make_shared<std::vector<myType>>();
foo.get()-> // now try to list symbols with caret right after the ->

but it didn't go for that either (same error message).

Dennis

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 2252
  • Hero Points: 283
Re: Edge case c++ auto keyword and list-symbols
« Reply #5 on: December 01, 2017, 11:46:22 pm »
I'm putting in some fixes for 22.0.1 that should cover this problem.

As far as I can tell, std::make_shared<> is not part of GCC 4.x, so you will need a compiler configuration of GCC 5 or later to make this work.  I've tested with GCC 5.3, GCC 7.1, and Visual Studio 2015.  Your test case works in each case, when forcing list-symbols by hitting Alt+Dot.  Unfortunately, this one is a bit too complex and time consuming for auto-list members and/or auto-complete to handle it within the allotted timeout.

Also, you will want to rebuild your workspace tag file and your compiler tag files when you get 22.0.1.

mrothman

  • Senior Community Member
  • Posts: 114
  • Hero Points: 1
Re: Edge case c++ auto keyword and list-symbols
« Reply #6 on: December 04, 2017, 05:21:20 pm »
Thanks Dennis.  I did move to a later version of gcc as I mentioned in the earlier post, and it didn't fix the issue. But I think you're saying I also will need 22 and your fixes, right?

On a partially related topic, once I updated to the latest hotfixes for 21, I ended up with slower response for list-symbols in general.  I decided to tune things, but I seem to have gotten myself in a ditch: for many variables in my functions, I now get NO auto listing of symbols. And when I force the listing, I get the message: "Auto list members found maximum number of symbols" (and still no drop down).  Can you suggest which configuration option I tweaked and should have left alone? I don't see anything obvious, and I've tried increasing most of the maximums in the Context Tagging options section.

Dennis

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 2252
  • Hero Points: 283
Re: Edge case c++ auto keyword and list-symbols
« Reply #7 on: December 04, 2017, 06:49:33 pm »
The fixes will be in 22.0.1, which is not out yet.

If you feel that you have messed up the Context Tagging performance settings, you can use Tools > Options > Import/Export Options > Restore Default Options... to selectively restore that category of options back to the default settings.