Geant4 Version: 10.7.p04
Operating System: MacOS 10.15.7
Compiler/Version: Apple Clang 12.0.0
CMake Version: 3.15.2
I am getting a weird compiler warning, which I don’t think should happen at all. I have a class with a G4String data member, in which I’ve followed the Rule of Five to declare the various copy constructors, thus:
// Use default copy/move semantics
G4LatticeReader(const G4LatticeReader&) = default;
G4LatticeReader(G4LatticeReader&&) = default;
G4LatticeReader& operator=(const G4LatticeReader&) = default;
G4LatticeReader& operator=(G4LatticeReader&&) = default;
I’m getting a compiler warning for the two assignment operators, which claims (incorrectly!) that G4String doesn’t have the corresponding operators:
./include/G4LatticeReader.hh:46:20: warning: explicitly defaulted copy
assignment operator is implicitly deleted [-Wdefaulted-function-deleted]
G4LatticeReader& operator=(const G4LatticeReader&) = default;
^
./include/G4LatticeReader.hh:97:18: note: copy assignment operator of
'G4LatticeReader' is implicitly deleted because field 'fDataDir' has no
copy assignment operator
const G4String fDataDir; // Directory path ($G4LATTICEDATA)
^
./include/G4LatticeReader.hh:47:20: warning: explicitly defaulted move
assignment operator is implicitly deleted [-Wdefaulted-function-deleted]
G4LatticeReader& operator=(G4LatticeReader&&) = default;
^
./include/G4LatticeReader.hh:97:18: note: move assignment operator of
'G4LatticeReader' is implicitly deleted because field 'fDataDir' has no
move assignment operator
const G4String fDataDir; // Directory path ($G4LATTICEDATA)
^
2 warnings generated.
But that is trivially incorrect. From G4String.hh
:
inline G4String(G4String&&) = default;
and
inline G4String& operator=(G4String&&) = default;
Has anyone else seen this kind of compiler warning? Or do I just have some incorrect compiler option going on?