geodynamics / aspect

A parallel, extensible finite element code to simulate convection in both 2D and 3D models.
https://aspect.geodynamics.org/
Other
228 stars 238 forks source link

Worldbuilder causes compile warnings #2782

Closed gassmoeller closed 5 years ago

gassmoeller commented 5 years ago

The current version of the WorldBuilder produces warnings with gcc 6.2.0 as follows:

[1/2] Building CXX object CMakeFiles/a...ib/WorldBuilder/source/parameters.cc.o
FAILED: CMakeFiles/aspect.dir/contrib/WorldBuilder/source/parameters.cc.o 
/usr/bin/mpicxx   -DDEBUG -DTBB_DO_ASSERT=1 -DTBB_USE_DEBUG -DASPECT_HAVE_LINK_H=1 -DASPECT_SOURCE_DIR=\"/home/dealii/aspect\" -DASPECT_USE_FP_EXCEPTIONS=1 -DASPECT_USE_SHARED_LIBS=1 -DASPECT_USE_WORLD_BUILDER=1 -I../include -Iinclude -I../contrib/catch -I../contrib/WorldBuilder/include -I/home/dealii/dealii-v8.5.0/include -I/home/dealii/dealii-v8.5.0/include/deal.II/bundled -I/usr/lib/openmpi/include/openmpi/opal/mca/event/libevent2021/libevent -I/usr/lib/openmpi/include/openmpi/opal/mca/event/libevent2021/libevent/include -I/usr/lib/openmpi/include -I/usr/lib/openmpi/include/openmpi -I/home/dealii/libs/parmetis-4.0.3/include -I/home/dealii/libs/trilinos-release-12-10-1/include -I/home/dealii/libs/superlu_dist_5.1.2/include -I/home/dealii/libs/petsc-3.7.6/include -I/home/dealii/libs/hdf5-1.10.1/include -I/home/dealii/libs/oce-OCE-0.18.1/include/oce -I/home/dealii/libs/p4est-2.0/FAST/include -I/home/dealii/libs/slepc-3.7.3/include -Werror   -pedantic -fPIC -Wall -Wextra -Wpointer-arith -Wwrite-strings -Wsynth -Wsign-compare -Wswitch -Woverloaded-virtual -Wno-long-long -Wno-placement-new  -Wno-literal-suffix -fopenmp-simd -std=c++14 -Wno-parentheses -Wno-unused-local-typedefs -Og -ggdb -Wa,--compress-debug-sections -Winvalid-pch -include /home/dealii/aspect/tester-build/cotire/aspect_CXX_prefix.hxx -MMD -MT CMakeFiles/aspect.dir/contrib/WorldBuilder/source/parameters.cc.o -MF CMakeFiles/aspect.dir/contrib/WorldBuilder/source/parameters.cc.o.d -o CMakeFiles/aspect.dir/contrib/WorldBuilder/source/parameters.cc.o -c ../contrib/WorldBuilder/source/parameters.cc
In file included from ../contrib/WorldBuilder/include/rapidjson/schema.h:36:0,
                 from ../contrib/WorldBuilder/include/world_builder/parameters.h:30,
                 from ../contrib/WorldBuilder/source/parameters.cc:33:
../contrib/WorldBuilder/include/rapidjson/internal/regex.h: In member function ‘void rapidjson::internal::GenericRegex<Encoding, Allocator>::Parse(rapidjson::internal::DecodedStream<InputStream, Encoding>&) [with InputStream = rapidjson::GenericStringStream<rapidjson::UTF8<> >; Encoding = rapidjson::UTF8<>; Allocator = rapidjson::CrtAllocator]’:
../contrib/WorldBuilder/include/rapidjson/internal/regex.h:473:16: error: ‘n’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
           else if (m > n)
                ^~
../contrib/WorldBuilder/include/rapidjson/internal/regex.h:273:30: note: ‘n’ was declared here
                     unsigned n, m;
                              ^
../contrib/WorldBuilder/include/rapidjson/internal/regex.h: In static member function ‘static bool rapidjson::internal::Schema<SchemaDocumentType>::IsPatternMatch(const RegexType*, const Ch*, rapidjson::SizeType) [with SchemaDocumentType = rapidjson::GenericSchemaDocument<rapidjson::GenericValue<rapidjson::UTF8<> > >]’:
../contrib/WorldBuilder/include/rapidjson/internal/regex.h:790:15: error: ‘codepoint’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
               if (codepoint >= (r.start & ~RegexType::kRangeNegationFlag) && codepoint <= r.end)
               ^~
../contrib/WorldBuilder/include/rapidjson/internal/regex.h:734:20: note: ‘codepoint’ was declared here
           unsigned codepoint;
                    ^~~~~~~~~
../contrib/WorldBuilder/include/rapidjson/internal/regex.h: In member function ‘bool rapidjson::GenericSchemaValidator<SchemaDocumentType, OutputHandler, StateAllocator>::Key(const Ch*, rapidjson::SizeType, bool) [with SchemaDocumentType = rapidjson::GenericSchemaDocument<rapidjson::GenericValue<rapidjson::UTF8<> > >; OutputHandler = rapidjson::BaseReaderHandler<rapidjson::UTF8<>, void>; StateAllocator = rapidjson::CrtAllocator]’:
../contrib/WorldBuilder/include/rapidjson/internal/regex.h:790:15: error: ‘codepoint’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
               if (codepoint >= (r.start & ~RegexType::kRangeNegationFlag) && codepoint <= r.end)
               ^~
../contrib/WorldBuilder/include/rapidjson/internal/regex.h:734:20: note: ‘codepoint’ was declared here
           unsigned codepoint;
                    ^~~~~~~~~
cc1plus: all warnings being treated as errors
ninja: build stopped: subcommand failed.

This prevents me from compiling in the tester docker container, because I can also not disable the world builder (-D ASPECT_WITH_WORLD_BUILDER=OFF has no effect, if the world build is there, it tries to compile it).

MFraters commented 5 years ago

Hey Rene,

are you using the current version in aspect, or the most resent version of the world builder? The 'n' warning should be gone in the new versions.

My gcc testers use gcc 6.5.0, and I see no warnings or errors there (https://travis-ci.org/GeodynamicWorldBuilder/WorldBuilder/jobs/484079093). I will go through the compiler flags to see if I can reproduce the codepoint error.

I will also test the world builder flag, and fix it if necessary.

gassmoeller commented 5 years ago

I use the latest version that is in aspect. With the latest version of the Worldbuilder itself the warning about n is gone, but the codepoint error is still there.

MFraters commented 5 years ago

I have now also tested it in 4.9 and 6.5.0 (through travis) with the flags -Wmaybe-uninitialized and -Werror=maybe-uninitialized and I do not see the warning. The problem itself is easy to fix, but the weird thing is that just 2 lines later the value is set anyway. I will try to install gcc 6.2 on travis to see whether I can reproduce the error, before I fix it.

MFraters commented 5 years ago

I have not been able to reproduce the problem (installing gcc 6.2 is a hassle), so I just initialized the value. Could you update to world builder to see whether the problem is gone?

I think pull request #2778 should fix the other issue.

gassmoeller commented 5 years ago

Yes that fixed it. The newest world build compiles without issues. I suppose the problems are really just caught in the tester docker container (with deal.II 8.5). Thanks for the quick response!

MFraters commented 5 years ago

Great!