I was trying to use clang to compile some Qt 5.1.0 code and came across a compile error when including the file QtCore/qabstractitemmodel.h.<br><br>Simplyfying the code, I created bar.cpp:<br><br>class bar<br>{<br> friend int foo(int seed = 0);<br>
};<br><br>inline int foo(int seed) { return seed; }<br><br>int main()<br>{<br> bar bletch;<br>}<br><br>The error I get using clang version 3.4 (trunk 187329) is:<br><br>bar.cpp:3:14: error: friend declaration specifying a default argument must be a definition<br>
friend int foo(int seed = 0);<br> ^<br>bar.cpp:6:12: error: friend declaration specifying a default argument must be the only declaration<br>inline int foo(int seed) { return seed; }<br> ^<br>bar.cpp:3:14: note: previous declaration is here<br>
friend int foo(int seed = 0);<br> ^<br>2 errors generated.<br><br>Moving the initializer "seed = 0" from the friend declaration to the inline declaration compiles without problem.<br><br>This code compiles fine with clang 3.3 and gcc 4.7.3.<br>
<br>Robert Ankeney<br><br>