Bug 6500 – Show template instantiation values too

Status
RESOLVED
Resolution
FIXED
Severity
enhancement
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2011-08-15T14:30:20Z
Last change time
2021-01-24T05:45:00Z
Keywords
diagnostic
Assigned to
No Owner
Creator
bearophile_hugs

Comments

Comment #0 by bearophile_hugs — 2011-08-15T14:30:20Z
This enhancement is of minor priority. A small C++ program: template <int x> int foo(int y) { unsigned int z = 10; return y < z; } int main() { foo<5>(6); return 0; } On it G++ 4.6 shows a warning, and it shows "x = 5" (the template instantiation value) too: ...>g++ -Wall test.cpp -o test test.cpp: In function 'int foo(int) [with int x = 5]': test.cpp:7:13: instantiated from here test.cpp:4:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] I'd like DMD to do something similar, and show the template instatiation values when it gives warnings: int foo(int x)() { return x; static if (x > 10) return x + 1; } int main() { return foo!(12)(); } DMD 2.054 gives: test.d(4): Warning: statement is not reachable This enhancement request applies to warnings like the signed/unsigned one in pull 119 too: https://github.com/D-Programming-Language/dmd/pull/119
Comment #1 by maxhaton — 2021-01-24T05:45:00Z
The compiler does tell you when something broke inside a template (*and* give you parameters) Up to 2.063 : Failure with output: ----- onlineapp.d(2): Error: static assert (0) is false onlineapp.d(5): instantiated from here: foo!(12)