1
votes

I noticed today that one of my header files was still using an auto_ptr<> template.

I am using -std=c++11 to make sure to compile in C++11 and -pedantic and -Werror to detect deprecated usage. So I would imagine that I should have had an error while compiling that header since auto_ptr is marked as deprecated, what do you think?

There is part of the class with the offensive definition:

class server
{
[...snip...]

private:
    std::auto_ptr<snap_listen_thread>     f_listen_runner;
    std::auto_ptr<snap_thread>            f_listen_thread;

[...snip...]
};

The following lists all the command line options. I am using g++ version 4.8.2 (Ubuntu 4.8.2-19ubuntu1) and as we can see I have -pedantic and -Werror in the list:

cd /home/snapwebsites/BUILD/snapwebsites/lib && /usr/bin/c++ -DCONTROLLED_VARS_DEBUG -DDEBUG -DQT_CORE_LIB -DQT_DEBUG -DQT_XMLPATTERNS_LIB -DQT_XML_LIB -D_DEBUG -Dsnapwebsites_EXPORTS -std=c++11 -Werror -Wall -Wextra -pedantic -Wcast-align -Wcast-qual -Wctor-dtor-privacy -Wdisabled-optimization -Winit-self -Wlogical-op -Wmissing-include-dirs -Woverloaded-virtual -Wredundant-decls -Wshadow -Wsign-promo -Wstrict-null-sentinel -Wstrict-overflow=4 -Wundef -Wno-unused -Wunused-variable -Wno-variadic-macros -Wno-parentheses -Wno-unknown-pragmas -Wwrite-strings -Wswitch -fdiagnostics-show-option -fPIC -Wunused-parameter -Wfloat-equal -Wold-style-cast -Wnoexcept -g -g -O0 -fPIC -I/home/snapwebsites/snapwebsites -I/home/snapwebsites/snapwebsites/lib -I/home/snapwebsites/BUILD/snapwebsites -I/home/snapwebsites/BUILD/snapwebsites/lib -I/home/snapwebsites/BUILD/dist/include -I/home/snapwebsites/BUILD/dist/include/advgetopt -I/home/snapwebsites/BUILD/dist/include/QtSerialization -isystem /usr/include/qt4 -isystem /usr/include/qt4/QtXmlPatterns -isystem /usr/include/qt4/QtXml -isystem /usr/include/qt4/QtCore -isystem /usr/include/qt4/QtDesigner -isystem /usr/include/qt4/QtDeclarative -isystem /usr/include/qt4/QtScriptTools -isystem /usr/include/qt4/QtDBus -isystem /usr/include/qt4/QtSql -isystem /usr/include/qt4/QtOpenGL -isystem /usr/include/qt4/QtNetwork -isystem /usr/include/qt4/QtWebKit -isystem /usr/include/qt4/QtHelp -isystem /usr/include/qt4/QtUiTools -isystem /usr/include/qt4/QtTest -isystem /usr/include/qt4/QtScript -isystem /usr/include/qt4/QtSvg -isystem /usr/include/qt4/Qt3Support -isystem /usr/include/qt4/QtGui -isystem /usr/share/qt4/mkspecs/default -isystem /usr/include/proc -o CMakeFiles/snapwebsites.dir/snap_initialize_website.cpp.o -c /home/snapwebsites/snapwebsites/lib/snap_initialize_website.cpp

Could there be a bug in g++ that it would not yet detect such deprecated templates once in a while?

1
Are all those includes really necessary to reproduce the problem?Lightness Races in Orbit
-pedantic and -Werror influence compiler behavior, not library behavior.Ignacio Vazquez-Abrams
@LightnessRacesinOrbit, the command line is auto-generated by cmake. We use Qt and a few other libraries... each .cpp does not require all the -isystem and -I by there is no reason for which we would want to have a specific list of includes for each file.Alexis Wilke
@IgnacioVazquez-Abrams, I'm not too sure I understand your comment here. I'm not trying to change how the library functions, only to have the compiler tell me that some things I use are deprecated.Alexis Wilke
If the library doesn't somehow tell the compiler that it should be deprecated under certain circumstances then the compiler in turn won't tell you.Ignacio Vazquez-Abrams

1 Answers

0
votes

As mentioned in one of my comments, with the help of some other people, I found out that the -isystem command line option is the culprit.

g++ marks everything with a do not warn about this flag and this when referencing anything from those libraries and whatever they included has the flag set... Unfortunately many of the libraries (a bit Qt and especially log4cplus) do not compile without warnings.