Warning: definition of implicit copy constructor is deprecated

前端 未结 3 1283
终归单人心
终归单人心 2020-12-25 13:20

I have a warning in my C++11 code that I would like to fix correctly but I don\'t really know how. I have created my own exception class that is derived from std::runt

3条回答
  •  时光取名叫无心
    2020-12-25 13:41

    Note: the same happens for much different code but I'm writing it here in case someone gets the same warning.

    There was a bug in GCC versions 6.4 - 9.0 where using declarations for base_type's operator= and base_type's ctor in types inheritted from base_type which was a class template did not actually created copy/move ctor/operators (ending in very unexpected compiler errors that an object can not be copied/moved).

    Since GCC 9.0, the bug is fixed but it creates this warning instead. The warning is wrong and should not appear (the using explicitly declares constructors/operators).

    • Example code with workarounds and GCC version comparison: https://godbolt.org/z/WgIH4c
    • GCC bug report: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89381
    • another GCC bug report: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92145
    • Origin of this discovery: https://github.com/boostorg/spirit/issues/465

提交回复
热议问题