Different format for template error in GCC?

GCC has a very detailed format for template error messages:

... some_class<A,B,C> [with int A = 1, int B = 2, int C = 3] 

Any chance to do this to show something like:

 ... some_class<1,2,3> 
0
source share
3 answers

You will lose track of which template the specialization came from:

 template<int A, int B> class X { void f(); }; template<int A> class X<A, 2> { void f(); }; int main() { X<1, 2>().f(); X<2, 1>().f(); } 

GCC Outputs

 m.cpp: In function 'int main()': m.cpp:6:12: error: 'void X<A, 2>::f() [with int A = 1]' is private m.cpp:10:19: error: within this context m.cpp:2:12: error: 'void X<A, B>::f() [with int A = 2, int B = 1]' is private m.cpp:11:19: error: within this context 

If he simply said X<1, 2> and X<2, 1> , you will lose the important information contained in this diagnostic.

+3
source

Not unless you want to maintain a private GCC source branch.

Although it is wise to want this for class templates, function templates can overload each other and have different lists of template arguments for the same function. Then the last style of error will be mixed.

+1
source

Use the -fno-pretty-templates option. This does what you want and also omits the default template arguments.

+1
source

All Articles