[cfe-dev] Clang compile error

Robert Ankeney rrankene at gmail.com
Fri Aug 9 05:42:00 PDT 2013


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.

Simplyfying the code, I created bar.cpp:

class bar
{
  friend int foo(int seed = 0);
};

inline int foo(int seed) { return seed; }

int main()
{
  bar bletch;
}

The error I get using clang version 3.4 (trunk 187329) is:

bar.cpp:3:14: error: friend declaration specifying a default argument must
be a definition
  friend int foo(int seed = 0);
             ^
bar.cpp:6:12: error: friend declaration specifying a default argument must
be the only declaration
inline int foo(int seed) { return seed; }
           ^
bar.cpp:3:14: note: previous declaration is here
  friend int foo(int seed = 0);
             ^
2 errors generated.

Moving the initializer "seed = 0" from the friend declaration to the inline
declaration compiles without problem.

This code compiles fine with clang 3.3 and gcc 4.7.3.

Robert Ankeney
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20130809/1d337c27/attachment.html>


More information about the cfe-dev mailing list