Hi,
I've just started porting my C++ application to Linux with Winelib.
Upon first attempts to compile, I've received a wall of "warning: returning reference to temporary" on Wine's headers from g++. All of those seem to stem from guidgen.h definition of __wine_uuidof / __CRT_UUID_DECL for C++.
All in all, g++ seems to be right -- we are indeed returning a reference to a IID struct that's allocated on the stack.
If I remove the '&' in this definition (in guidgen.h): template<typename T> const GUID &__wine_uuidof(); the warnings stop, but then I wonder, did the original author have some good reasoning for returning a reference in the first place?
Thanks.
On 7/29/12 4:32 PM, Ilya Konstantinov wrote:
Hi,
I've just started porting my C++ application to Linux with Winelib.
Upon first attempts to compile, I've received a wall of "warning: returning reference to temporary" on Wine's headers from g++. All of those seem to stem from guidgen.h definition of __wine_uuidof / __CRT_UUID_DECL for C++.
All in all, g++ seems to be right -- we are indeed returning a reference to a IID struct that's allocated on the stack.
I don't see these warnings here. Also Wine has the same code for __uuidof as mingw-w64, which is much more widely used with g++ (Wine is mostly tested on C), and I never heard about such problem. Do you have any idea about what could be different in your setup? What's your g++ version?
If I remove the '&' in this definition (in guidgen.h): template<typename T> const GUID &__wine_uuidof(); the warnings stop, but then I wonder, did the original author have some good reasoning for returning a reference in the first place?
The idea is that if matches closer to the meaning of __uuidof, which should return a reference to constant IID structure. I'd expect compiler to be smart enough to produce same code without the reference anyway (after all it's an inline function), but still being more explicit would be nice. Could you please test if the attached patch fixes the problem for you?
Jacek
On Sun, Jul 29, 2012 at 9:47 PM, Jacek Caban jacek@codeweavers.com wrote:
Upon first attempts to compile, I've received a wall of "warning:
returning reference to temporary" on Wine's headers from g++. All of those seem to stem from guidgen.h definition of __wine_uuidof / __CRT_UUID_DECL for C++.
I don't see these warnings here. Also Wine has the same code for __uuidof as mingw-w64, which is much more widely used with g++ (Wine is mostly tested on C), and I never heard about such problem. Do you have any idea about what could be different in your setup? What's your g++ version?
I'm using gcc version 4.6.3 (Ubuntu/Linaro 4.6.3-1ubuntu5) to build my Winelib app.
As to the difference from mingw-w64, I see different code in there: http://mingw-w64.svn.sourceforge.net/viewvc/mingw-w64?view=revision&revi...
The idea is that if matches closer to the meaning of __uuidof, which should
return a reference to constant IID structure.
Understood.
I'd expect compiler to be smart enough to produce same code without the reference anyway (after all it's an inline function), but still being more explicit would be nice. Could you please test if the attached patch fixes the problem for you?
Yep, it does.
On 07/30/12 13:13, Ilya Konstantinov wrote:
On Sun, Jul 29, 2012 at 9:47 PM, Jacek Caban <jacek@codeweavers.com mailto:jacek@codeweavers.com> wrote:
Upon first attempts to compile, I've received a wall of "warning: returning reference to temporary" on Wine's headers from g++. All of those seem to stem from guidgen.h definition of __wine_uuidof / __CRT_UUID_DECL for C++. I don't see these warnings here. Also Wine has the same code for __uuidof as mingw-w64, which is much more widely used with g++ (Wine is mostly tested on C), and I never heard about such problem. Do you have any idea about what could be different in your setup? What's your g++ version?
I'm using gcc version 4.6.3 (Ubuntu/Linaro 4.6.3-1ubuntu5) to build my Winelib app.
As to the difference from mingw-w64, I see different code in there: http://mingw-w64.svn.sourceforge.net/viewvc/mingw-w64?view=revision&revi... http://mingw-w64.svn.sourceforge.net/viewvc/mingw-w64?view=revision&revision=4279
The idea is that if matches closer to the meaning of __uuidof, which should return a reference to constant IID structure.
Understood.
I'd expect compiler to be smart enough to produce same code without the reference anyway (after all it's an inline function), but still being more explicit would be nice. Could you please test if the attached patch fixes the problem for you?
Yep, it does.
I've tested it more and sent a patch.
Jacek
Hi Jacek,
I just realized what was the difference in my case. I was including the system headers manually with -I/usr/include/wine/windows as opposed to -isystem/usr/include/wine/windows (as winegcc/wineg++ does it).
gcc suppresses warnings in system headers (when using -isystem): http://gcc.gnu.org/onlinedocs/cpp/System-Headers.html
On Tue, Jul 31, 2012 at 11:38 AM, Jacek Caban jacek@codeweavers.com wrote:
On 07/30/12 13:13, Ilya Konstantinov wrote:
On Sun, Jul 29, 2012 at 9:47 PM, Jacek Caban jacek@codeweavers.comwrote:
Upon first attempts to compile, I've received a wall of "warning:
returning reference to temporary" on Wine's headers from g++. All of those seem to stem from guidgen.h definition of __wine_uuidof / __CRT_UUID_DECL for C++.
I don't see these warnings here. Also Wine has the same code for __uuidof as mingw-w64, which is much more widely used with g++ (Wine is mostly tested on C), and I never heard about such problem. Do you have any idea about what could be different in your setup? What's your g++ version?
I'm using gcc version 4.6.3 (Ubuntu/Linaro 4.6.3-1ubuntu5) to build my Winelib app.
As to the difference from mingw-w64, I see different code in there:
http://mingw-w64.svn.sourceforge.net/viewvc/mingw-w64?view=revision&revi...
The idea is that if matches closer to the meaning of __uuidof, which
should return a reference to constant IID structure.
Understood.
I'd expect compiler to be smart enough to produce same code without the reference anyway (after all it's an inline function), but still being more explicit would be nice. Could you please test if the attached patch fixes the problem for you?
Yep, it does.
I've tested it more and sent a patch.
Jacek