Le 03/11/13 11:19, Krzysztof Czainski a écrit :
2013/11/2 Vicente J. Botet Escriba <vicente.botet@wanadoo.fr>
Le 02/11/13 12:02, Krzysztof Czainski a écrit :

Hi,

I've been trying to writhe a non-inline move constructor, to place its' implementation in a .cpp file. I'm having problems compiling my code, which I managed to simplify (after examining output of the preprocessor) down to this short code snippet:

#include <boost/move/core.hpp>

struct X
{
    X( ::boost::rv< X >& x );
    operator ::boost::rv<X>&() { return *static_cast< ::boost::rv<X>* >(this); }
};

X::X( ::boost::rv< X >& x ) {}

Compiling a .cpp file with the above contents gives me:

a.cpp:41:1: error: prototype for 'X::X(boost::rv<X>&)' does not match any in class 'X'
 X::X( ::boost::rv< X >& x ) {}
 ^
a.cpp:35:8: error: candidates are: X::X(const X&)
 struct X
        ^
a.cpp:37:5: error: X::X(boost::rv<X>&)
     X( ::boost::rv< X >& x );
     ^

I'm using MinGW gcc 4.8.1 in default -std mode (not-C++11 mode), boost-1.54.
It works for me with clang-3.1 and clang-3.2, but not with gcc :( Really curious.


Am I doing something wrong here, or is it a bug in the compiler?

I would say that it is a bug on the compiler.

Best,
Vicente

Thanks for checking this out, Vincente.

I simplified it a bit more, found out, that it has to do with attribute may_alias, and reported it to MinGW:
https://sourceforge.net/p/mingw/bugs/2126/

I also came up with a workaround, an example of which can be found in the attached files. 

Glad to see that you know where is the problem.

Ion, may I suggest you to add this on the documentation?

Best,
Vicente