Details
-
Bug
-
Resolution: Done
-
P3: Somewhat important
-
Qt Creator 4.11.0
-
None
-
Windows 10, MSVC2017, Qt 5.14.0
Description
Consider the following code (add a breakpoint at any line inside the function func):
#include <QCoreApplication> template<typename T> T func(T val) { return val * 2; // Add a breakpoint here } int main(int argc, char *argv[]) { QCoreApplication a(argc, argv); func(1); return a.exec(); }
The implementation of the function is irrelevant, what is important is that we have just a single instantiation func<int>. Everything works as expected (we stop at the breakpoint), but if we add one more instantiation, something changes:
#include <QCoreApplication> template<typename T> T func(T val) { return val * 2; // Add a breakpoint here } int main(int argc, char *argv[]) { QCoreApplication a(argc, argv); func(1); func(1L); return a.exec(); }
Now we have two instantiations of the function (func<int>, func<long>), and this fact is reflected in the Breakpoints View. Now the debugger doesn't stop neither in func<int> nor func<long>.
Interestingly, if we add one more breakpoint somewhere before the call to func<T> (in the non-templated code), the debugger would stop on all 3 breakpoints. Looks like it needs some initialization that is performed on the first stop, and without this initialization the debugger never stops on breakpoint at the templated code that has multiple instantiations.
The behavior is 100% reproducible on my Windows 10 machine.