Author Topic: The data type of an 'auto' is not properly figured out by SE in C++  (Read 1109 times)

rowbearto

  • Senior Community Member
  • Posts: 2335
  • Hero Points: 132
See example below, look for "PROBLEM:"

This issue occurs on 26.0.1 Linux x64.

Code: [Select]
namespace some_namespace
{
    class SomeContext
    {
    public:
        template <class T> T* create(void* ptr, long long identifier = 0)
        {
            T* valToReturn = nullptr;
            return valToReturn;
        }
    }
    class SomeContext : public some_namespace::SomeContext
    {
    public:
        int xelem1;
        int xelem2;
    }
  }
};

using namespace some_namespace;

class ClassName2
{
public:
    int elem1;
    int elem2;
};

void somefunc(SomeContext& someContextObj)
{
    auto createdObj = someContextObj.create<ClassName2>(nullptr, 0);

    // PROBLEM:
    // Using "Preview" window on createdObj below shows that SlickEdit
    // thinks the type of "createdObj" is someContextObj.create<ClassName2>( nullptr, 0 )
    // but this is not correct. The type of createdObj should be "ClassName2 *"
    // Also doing -> after createdObj doesn't autolist, probably related to the
    // type of createdObj not getting properly determined.
    createdObj->;
}
« Last Edit: January 12, 2022, 10:40:44 PM by rowbearto »

Dennis

  • Senior Community Member
  • Posts: 3961
  • Hero Points: 517
Re: The data type of an 'auto' is not properly figured out by SE in C++
« Reply #1 on: January 13, 2022, 01:27:55 PM »
Reproduced.  The problem traces down to the template function.  We handle template replacement somewhat well with classes, but not as good with template functions.  I'll take a look at it.  Thanks for the good test case.

Dennis

  • Senior Community Member
  • Posts: 3961
  • Hero Points: 517
Re: The data type of an 'auto' is not properly figured out by SE in C++
« Reply #2 on: March 28, 2022, 10:21:49 PM »
There will be a fix for 26.0.2 which should help with cases like this.