ola icon indicating copy to clipboard operation
ola copied to clipboard

"template<class> class std::auto_ptr" is deprecated in C++11/C++14 (GCC6 default)

Open daveol opened this issue 9 years ago • 19 comments
trafficstars

When the rebuild for Fedora 24 triggered it failed. This was due to a deprecation warning that was treated as a error.

The deprecation warning was about template<class> class std::auto_ptr since this is used in protoc/CppGenerator.cpp on line 52 and line 57

The koji build job is here and the build log is here

daveol avatar Feb 05 '16 12:02 daveol

-Wno-deprecated-declarations appears to be the immediate workaround.

See also: http://stackoverflow.com/questions/2404115/is-auto-ptr-deprecated

This seems to imply it can be bypassed/fixed with some compiler flags: https://github.com/fuzzylite/fuzzylite/issues/65

peternewman avatar Feb 05 '16 13:02 peternewman

It would appear the main cause is: "The default mode for C++ is now -std=gnu++14 instead of -std=gnu++98."

peternewman avatar Feb 05 '16 13:02 peternewman

I can confirm this, since a build with -std=gnu++98 didn't fail

daveol avatar Feb 05 '16 14:02 daveol

For what it's worth, this is the patch I made for the fedora package:

diff --git a/configure.ac b/configure.ac
index ef31e09..3e98692 100644
--- a/configure.ac
+++ b/configure.ac
@@ -34,6 +34,9 @@ AC_PROG_LN_S
 AC_PROG_MAKE_SET
 AC_PROG_MKDIR_P

+# Ensure we use gnu++98 instead of c++14
+CPPFLAGS="$CPPFLAGS -std=gnu++98"
+
 # Checks for header files.
 AC_HEADER_DIRENT
 AC_HEADER_RESOLV

daveol avatar Feb 05 '16 16:02 daveol

Thanks for the confirmation @daveol . @nomis52 any feeling on how we should progress?

peternewman avatar Feb 06 '16 14:02 peternewman

did some more searching, auto_ptr is deprecated in c++11 and the replacement of it would be unique_ptr, which was only introduced in c++11...

daveol avatar Feb 25 '16 18:02 daveol

We've discussed this before so I'll put the notes here.

This comes down to Precise.

gcc 4.7 was the first to ship with -std=c++11 . The Ubuntu situation is:

  • Precise, gcc 4.6 , EOL Apr 2017
  • Trusty, gcc 4.8 , EOL Apr 2019

As a comparison Jesse uses gcc 4.9.

So on Apr 2017, I'll be more than happy to accept a patch switching to unique_ptr.

nomis52 avatar Feb 26 '16 16:02 nomis52

Until April 2017 though, it seems like we could do with a patch to detect -std=gnu++14 as the default and set it back to 98 or whatever so it builds correctly.

peternewman avatar Feb 28 '16 15:02 peternewman

See #1080 for some commits that detect when -std=gnu++11 and -std=gnu++98 are both available and then force gnu++98 to be added to the flags.

We could call this a fix or leave it until we've removed auto_ptr support? We may also be able to do something clever with macros to support both, but I don't know if it's worth the codebase hassle.

peternewman avatar May 30 '16 00:05 peternewman

I think the fix in #1080 is sufficient to close this.

nomis52 avatar May 30 '16 14:05 nomis52

Fixed in #1090 which will be in 0.10.3.

peternewman avatar Jun 02 '16 23:06 peternewman

Reopening.

Precise is no longer supported so we're free to switch to -std=c++11 and unique_ptr.

nomis52 avatar May 15 '17 15:05 nomis52

https://github.com/OpenLightingProject/ola/pull/1258 allows us to compile on C++11 (by disabling the errors) or C++98, so if we add new C++11 language features we'll need to break the older builds.

peternewman avatar Jun 30 '17 01:06 peternewman

I've just started using odb and c++, I had this issue while playing around with some stuff. I found that -Wno-deprecated-declarations (as suggested by peternewman) with -std=c++11 works for me (g++ on ubuntu 17.10)

davoc avatar Dec 11 '17 01:12 davoc

@davoc do you mean you had this issue with OLA, it should have been fixed in our releases since 0.10.5 so you don't need to do anything and don't get the error (it autodetects and adds the -Wno argument as necessary. Or are you saying this wasn't the case for you?

peternewman avatar Dec 11 '17 19:12 peternewman

Another C++11 thing to add back in. https://github.com/OpenLightingProject/ola/pull/1556#discussion_r279201906

peternewman avatar May 16 '19 13:05 peternewman

Personally I'd like to get master released as 0.11.0 before we require C++11, given it's had a lot of changes added and is pretty stable (and gives people on more random platforms a bit more C++11 support). We can then branch that and all future master commits can be C++11 capable (i.e. Ubuntu 14.04 compatible).

peternewman avatar May 16 '19 13:05 peternewman

It's a couple years later...any further thoughts/discussion/decision on whether to advance OLA to C++11?

I would be happy to contribute to the effort as time permits. I know everyone is busy.

Lotharyx avatar Apr 01 '22 23:04 Lotharyx

So, in 2021, we still can't use C++11, also not in the upcoming major version 0.11, but can only expect that in 0.12? That seems like an extremely conservative approach that make this project seem outdated and hinder clean packaging in distros.

Please reconsider.

kiilerix avatar Aug 10 '22 21:08 kiilerix