| Bug #92039 | GCC 9 warnings | ||
|---|---|---|---|
| Submitted: | 16 Aug 2018 8:38 | Modified: | 22 Aug 2018 12:51 |
| Reporter: | Steinar Gunderson | Email Updates: | |
| Status: | Closed | Impact on me: | |
| Category: | MySQL Server: Compiling | Severity: | S3 (Non-critical) |
| Version: | 8.0.15 | OS: | Any |
| Assigned to: | CPU Architecture: | Any | |
[16 Aug 2018 8:42]
Steinar Gunderson
Posted by developer:
Oh, I forgot to write: Making an explicit copy constructor will also disable the default constructor. So if you want it, you'll also need to do
Foo() {}
[22 Aug 2018 12:51]
Paul DuBois
Posted by developer: Fixed in 8.0.14. Configuration/build cleanup. No changelog entry needed.
[31 Oct 2018 19:53]
MySQL Verification Team
I still cannot compile current mysql trunk on current gcc trunk due to this:
../../mysys/my_init.cc:475:63: error: could not convert ‘{0, "Waiting for disk space", 0, ""}’ from ‘<brace-enclosed initializer list>’ to ‘PSI_stage_info’ {aka ‘PSI_stage_info_v1’}
475 | PSI_DOCUMENT_ME};
| ^
| |
| <brace-enclosed initializer list>
make[2]: *** [mysys/CMakeFiles/mysys.dir/my_init.cc.o] Error 1
any idea?
[1 Nov 2018 10:28]
Steinar Gunderson
Posted by developer: I'm unable to reproduce this. Save for a new GCC 9 internal compiler error that I'm reporting now (which forced me to use -DWITH_SYSTEM_LIBS=1), all of MySQL compiles warning-free with the latest GCC 9 snapshot I have here (20181019). Are you using any strange flags? What does the compile line for my_init.cc.o look like?
[21 Dec 2018 1:13]
Paul DuBois
Posted by developer: Fixed in 8.0.15. Code cleanup. No changelog entry needed.

Description: GCC 9 has some new warnings. In particular, it now warns about use of implicit copy constructors in classes with nontrivial destructors (and in a few other cases, such as operator=), which is deprecated in C++11: class Foo { ~Foo(); // nontrivial destructor (even if it is actually empty) }; void func(Foo a) { // ... } Foo b; func(b); // warning, invoking implicit Foo(Foo &), which is deprecated for Foo The fix is either to remove ~Foo() where possible, or to make the copy constructor explicit: class Foo { ~Foo(); Foo(Foo &) = default; // now explicit, so no longer deprecated }; However, do note that making an explicit copy constructor disables the implicit assignment operator. If you want it, you'll need to specify it: class Foo { ~Foo(); Foo(Foo &) = default; Foo &operator=(const Foo &) = default; // must be explicit due to previous line }; And this, in turn, disables the implicit move assignment operator. Since you want it back, you need to write: class Foo { ~Foo(); Foo(Foo &) = default; Foo(Foo &&) = default; // move constructor must be explicit because copy is Foo &operator=(const Foo &) = default; Foo &operator=(Foo &&) = default; // move assignment must be explicit because move is }; This is all rather cumbersome for virtual base classes, but that's what the standard says, and GCC has chosen to warn on the standard. See GCC bug #58407. How to repeat: N/A Suggested fix: Remove the destructor where possible. Otherwise, add the four lines as suggested.