I’ve updated my development machine to the just-released 12.04 version of Ubuntu, which apparently gave me a new version of GCC (4.6.3). Now source code that used to compile fine is giving me errors about the compiler-generated assignment operator:
source/local.cpp:1185:59: error: no match for ‘operator=’ in ‘olddata = stype::block_t((*(const oc::json_t*)(& local::database_t::getData(const sdata::uuid_t&, size_t*, sdata::override::type_t)((* & uuid), (& otype), (sdata::override::type_t)1u))), 0)’ source/local.cpp:1185:59: note: candidate is: source/sdata/block.hpp:13:7: note: sdata::block_t& sdata::block_t::operator=(sdata::block_t&) source/sdata/block.hpp:13:7: note: no known conversion for argument 1 from ‘sdata::block_t’ to ‘sdata::block_t&’
So far as I can tell, the compiler-generated operator= should have the signature foo& operator=(const foo&), not foo& operator=(foo&). Is this a bug in this version of GCC, or is my understanding wrong? I can’t find any references to this on the GCC bug-tracker, and I can’t believe that no one else has run into it.
(Google doesn’t make searching for terms that contain an equals sign easy, but with patience I found a single reference to this problem here, discussing GCC 4.6.2.)
I don’t know what’s correct, but GCC’s behavior definitely causes problems. I’m calling it a bug.
Oddly enough, it doesn’t seem to happen on every class, only a few, so until I can come up with a simple example, I can’t really file a bug-report on it.