Consider the following code sample:
#define ZERO(c) c.set(0) struct S { int a; int b; }; template <class T> class C { T t; public: void set(int x) { t = x; } }; void foo(C<S> &c) { ZERO(c); } When compiled with clang, the instantiation backtrace shows the point of instantiation within the ZERO macro: #> clang ./tst.cc ./tst.cc:15:23: error: no viable overloaded '=' void set(int x) { t = x; } ~ ^ ~ ./tst.cc:20:3: note: in instantiation of member function 'C<struct S>::set' requested here ZERO(c); ^ ./tst.cc:1:19: note: instantiated from: #define ZERO(c) c.set(0) ^ ./tst.cc:3:8: note: candidate function (the implicit copy assignment operator) not viable: no known conversion from 'int' to 'struct S const' for 1st argument struct S ^ 3 diagnostics generated. By contract, gcc ignores the macro completely: #> ./install/bin/gcc -c ./tst.cc ./tst.cc: In member function void C<T>::set(int) [with T = S]: ./tst.cc:20:3: instantiated from here ./tst.cc:15:21: error: no match for operator= in this->C<S>::t = x ./tst.cc:3:8: note: candidate is: S& S::operator=(const S&) GCC should include macros in instantiation backtraces like clang does. -- Summary: Include macros in instantiation backtraces Product: gcc Version: unknown Status: UNCONFIRMED Severity: enhancement Priority: P3 Component: c++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: aaw at gcc dot gnu dot org http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45333