C++ delete function compile error occurs from difference between gcc 4.8.2 and 4.9.4

Jonathan Wakely jwakely.gcc@gmail.com
Tue Aug 31 08:24:43 GMT 2021


On Tue, 31 Aug 2021 at 08:11, 김륜현 via Gcc-help <gcc-help@gcc.gnu.org> wrote:
>
> Dear Sir,
> Hi, I tried to compile my source code using gcc-linaro-aarch64-linux-gnu-4.8-2013.09-01_linux(gcc 4.8.2)
> the error occurred like below
>
> ../compiler/llvm-mali/lib/Target/Bifrost/BifrostInstrInfo.h:56:47: error: use of deleted function ‘llvm::MachineInstr::MachineInstr(const llvm::MachineInstr&)’
>      PipeInfoTy(const MachineInstr &mi) : MI{mi} {}
>                                                ^
> In file included from ../compiler/llvm-mali/lib/Target/Bifrost/MCTargetDesc/BifrostMCInstOpdMap.h:18:0,
>                  from ../compiler/llvm-mali/lib/Target/Bifrost/MCTargetDesc/BifrostMCInst.h:14,
>                  from ../compiler/llvm-mali/lib/Target/Bifrost/BifrostRegisterInfo.h:12,
>                  from ../compiler/llvm-mali/lib/Target/Bifrost/BifrostFrameLowering.h:13,
>                  from ../compiler/llvm-mali/lib/Target/Bifrost/BifrostSubtarget.h:12,
>                  from ../compiler/llvm-mali/lib/Target/Bifrost/BifrostISelDAGToDAG.h:13,
>                  from ../compiler/llvm-mali/lib/Target/Bifrost/BifrostISelDAGToDAG.cpp:11:
> ../compiler/llvm/llvm/include/llvm/CodeGen/MachineInstr.h:276:3: error: declared here
>    MachineInstr(const MachineInstr &) = delete;
>    ^
> In file included from ../compiler/llvm-mali/lib/Target/Bifrost/BifrostSubtarget.h:14:0,
>                  from ../compiler/llvm-mali/lib/Target/Bifrost/BifrostISelDAGToDAG.h:13,
>                  from ../compiler/llvm-mali/lib/Target/Bifrost/BifrostISelDAGToDAG.cpp:11:
> ../compiler/llvm-mali/lib/Target/Bifrost/BifrostInstrInfo.h:56:47: error: use of deleted function ‘llvm::MachineInstr::~MachineInstr()’
>      PipeInfoTy(const MachineInstr &mi) : MI{mi} {}
>                                                ^
> In file included from ../compiler/llvm-mali/lib/Target/Bifrost/MCTargetDesc/BifrostMCInstOpdMap.h:18:0,
>                  from ../compiler/llvm-mali/lib/Target/Bifrost/MCTargetDesc/BifrostMCInst.h:14,
>                  from ../compiler/llvm-mali/lib/Target/Bifrost/BifrostRegisterInfo.h:12,
>                  from ../compiler/llvm-mali/lib/Target/Bifrost/BifrostFrameLowering.h:13,
>                  from ../compiler/llvm-mali/lib/Target/Bifrost/BifrostSubtarget.h:12,
>                  from ../compiler/llvm-mali/lib/Target/Bifrost/BifrostISelDAGToDAG.h:13,
>                  from ../compiler/llvm-mali/lib/Target/Bifrost/BifrostISelDAGToDAG.cpp:11:
> ../compiler/llvm/llvm/include/llvm/CodeGen/MachineInstr.h:279:3: error: declared here
>    ~MachineInstr() = delete;
>
> Here, I attach the code that i simply reconstructed for the private of the real code
>
> Please refer to below code for understanding error log
> (Assume AAA to MachineInstr / ZZZ to PipeInfoTy)
>
> #include <iostream>
> using namespace std;
>
> class AAA {
> public:
>     AAA(const AAA &) = delete;
>     AAA &operator=(const AAA &) = delete;
>     ~AAA() = delete;
> };
>
> class ZZZ {
>     const AAA &ca;
>
> public:
>     ZZZ (const AAA &aaa) : ca{aaa} {}
> };
>
> int main()
> {
>
> }
>
>
> I was looking for the solution and eventually changed the toolchain to gcc-linaro-4.9-2016.02-x86_64_aarch64-linux-gnu(gcc4.9.4)
>
> and I tried again. build was success.
>
> Build was successful and I read the gcc release note and compile option for checking cause
>
> But i don't know what the difference is.

There was a defect report against the C++11 standard, which was
implemented in GCC 4.9 but not in GCC 4.8:
https://wg21.link/cwg1288

So the code is relying on a feature which was not actually supported
in the original C++11 standard. You can work around it by using
ca(aaa) instead of ca{aaa}. That compiles with GCC 4.8 and all later
versions.


More information about the Gcc-help mailing list