Author |
Topic  |
|
superzmy
Senior Member
  
China
34 Posts |
Posted - Dec 22 2024 : 9:34:55 PM
|
struct StructA {}; class X { public: template<bool B> auto Foo1() const noexcept -> bool { return 1; }
template<bool B> auto Foo2(StructA * a) const noexcept -> bool { return 1; } };
void A() { X x; X * pX = new X{}; pX->template Foo1<true>(); //1 pX->Foo1<true>(); //2
StructA * a = nullptr; (&x)->template Foo2<true>(a); //3 ((X *) &x)->Foo2<true>(a); //4 } ----- Move input cursor to Foo1 or Foo2 (1/2/3/4) and test ctrl-shift-f (find reference). and only //2 will find success. |
|
feline
Whole Tomato Software
    
United Kingdom
19110 Posts |
Posted - Dec 23 2024 : 12:46:03 PM
|
Thank you for the clear sample code, I am seeing the same problems here. I have put in a bug report for this:
case=165345
If you run Find References on 1 or 2, and right click with the mouse in the Find References Results window, if you make sure "Display unknown/guess hits" is turned On, VA will list 3 and 4, since it recognises that the function name is used here, even though it isn't understanding the code properly. Not ideal, but perhaps helpful. |
zen is the art of being at one with the two'ness |
 |
|
superzmy
Senior Member
  
China
34 Posts |
Posted - Feb 08 2025 : 12:13:59 PM
|
gcc require to write XXX::template F<YYY>() to call static functions. but write XXX::F<YYY>() is ok to windows VS compile and VAX find referrence. Can I see this feature fix before I die ? Perhaps it just needs vax to ignore "template". |
 |
|
feline
Whole Tomato Software
    
United Kingdom
19110 Posts |
Posted - Feb 10 2025 : 09:43:40 AM
|
That would certainly explain the odd looking code.
Just trying to reproduce this here, to confirm it. I have installed MinGW gcc version 14.2.0 under Windows 10, and with the command:
gcc cppConsoleGccTest.cpp
I cannot get even a very simple test case to compile, due to:
undefined reference to `operator new(unsigned long long)'
one online answer says that gcc doesn't compile C++ code. |
zen is the art of being at one with the two'ness |
 |
|
superzmy
Senior Member
  
China
34 Posts |
Posted - Feb 13 2025 : 9:53:31 PM
|
quote: Originally posted by feline
That would certainly explain the odd looking code.
Just trying to reproduce this here, to confirm it. I have installed MinGW gcc version 14.2.0 under Windows 10, and with the command:
gcc cppConsoleGccTest.cpp
I cannot get even a very simple test case to compile, due to:
undefined reference to `operator new(unsigned long long)'
one online answer says that gcc doesn't compile C++ code.
Even you compile in linux, the command is not well. g++ a.cpp gcc -lstdc++
and you should use https://godbolt.org/ to test any code cross platform and compiler |
Edited by - superzmy on Feb 13 2025 9:55:13 PM |
 |
|
feline
Whole Tomato Software
    
United Kingdom
19110 Posts |
Posted - Feb 14 2025 : 08:39:20 AM
|
"gcc -lstdc++" does not work for me, I still get the error about "operator new".
"g++" is working for me. Using "g++" under Windows, version 14.2.0, the following code file compiles without any errors or warnings:
#include <iostream>
int main()
{
std::cout << "Hello World!\n";
}
struct StructA {};
class testClassHoldingTemplateFunctions
{
public:
static void SimpleMemberFunc() {}
template<bool B>
static bool SimpleTemplateFunc(StructA *a) { return true; }
};
void TestFindReferencesTemplateMememberFunctions()
{
testClassHoldingTemplateFunctions * pX = new testClassHoldingTemplateFunctions{};
StructA * a = nullptr;
pX->SimpleTemplateFunc<true>(a); // calling static member without template keyword
pX->template SimpleTemplateFunc<true>(a); // calling static member with template keyword
}
The same code compiles quite happily using the godbolt.org link you posted as well.
In both cases, I have added some invalid code, to make sure the compiler does throw an error on obviously invalid code.
So far I cannot reproduce the need for the template keyword. I have made sure I am calling a static template member function. |
zen is the art of being at one with the two'ness |
 |
|
superzmy
Senior Member
  
China
34 Posts |
Posted - Feb 20 2025 : 10:28:23 PM
|
You shouldn't debate whether the template is necessary. As long as the compiler accepts the template as valid syntax, vax should support it. ------ template<typename TA1> struct B { template<int> static void F1(int) {} };
template<typename TA1> struct D : B<TA1> { template<typename TA2> static void call() { B<TA1>::template F1<1>(1); // <- this "template" is required in gcc } };
int main() { D<int>::call<int>(); }
|
Edited by - superzmy on Feb 20 2025 10:29:48 PM |
 |
|
feline
Whole Tomato Software
    
United Kingdom
19110 Posts |
Posted - Feb 21 2025 : 06:56:14 AM
|
I agree and accept that this is a bug, and I have already put in the bug report for this.
But, if the template keyword is necessary then we have a bug that a lot of people who work on cross platform code are guaranteed to encounter. If the template keyword is optional then we have a more limited bug that is likely to effect a smaller number of people. Which is why I wanted to check this, since this is an important distinction, and can help us when prioritising the outstanding bugs.
I hope this makes sense and explains my thinking here. |
zen is the art of being at one with the two'ness |
 |
|
|
Topic  |
|