Starting with version 2.6.1, the C ++ protobuf compiler generates only copy constructors and copy assignment operators. But if your compiler supports optimizing the return value (and the conditions for this are met), the copy constructor will not be called in any case.
You can add some print statements to the generated copy constructor code of your messages to see if they are actually called or not. You can also do this by writing the protoc plugin so that it persists between protoc calls.
source share