Bug or feature? C++ code that no longer compiles under GCC 4.2

Daniel Drake ddrake@brontes3d.com
Thu Aug 30 16:55:00 GMT 2007


On Thu, 2007-08-30 at 10:05 +1000, Jonathan Adamczewski wrote:
> I don't have gcc-4.2 handy - does changing this to a const reference 
> solve the problem? i.e
> 
> template<typename Op>
> void foo(const Op& op) { op(); }

Thanks for the suggestion, it doesn't help:

test.cpp: In member function 'void My::test()':
test.cpp:12: error: invalid initialization of non-const reference of
type 'void (&)()' from a temporary of type 'void ()()'
test.cpp:4: error: in passing argument 1 of 'void foo(const Op&) [with
Op = void ()()]'

-- 
Daniel Drake
Brontes Technologies, A 3M Company
http://www.brontes3d.com/opensource



More information about the Gcc mailing list