Closed lindsayad closed 2 years ago
We'll need to fix this in tinydir
I've set up CI with GCC11 and I can't reproduce your error. Could you please double check your file? For example, it seems that the shadow warning is referring to moose/framework/src/utils/MooseUtils.C:693:15
.
Can you create a minimal code example that reproduces the problem? Please include compiler flags as well
If I compile
#include "tinydir.h"
#include <string>
#include <list>
std::list<std::string>
listDir(const std::string path, bool files_only)
{
std::list<std::string> files;
tinydir_dir dir;
dir.has_next = 0; // Avoid a garbage value in has_next (clang StaticAnalysis)
tinydir_open(&dir, path.c_str());
while (dir.has_next)
{
tinydir_file file;
file.is_dir = 0; // Avoid a garbage value in is_dir (clang StaticAnalysis)
tinydir_readfile(&dir, &file);
if (!files_only || !file.is_dir)
files.push_back(path + "/" + file.name);
tinydir_next(&dir);
}
tinydir_close(&dir);
return files;
}
then I get the warnings with the following compile line:
g++ -I/home/lindad/projects/moose/framework/contrib/tinydir/include tiny-dir-warning.cpp -O2 -o tiny-dir-warning.o -c -Wall
If I drop to -O1
optimization then I don't get the -Wmaybe-uninitialized
warning, and if I drop to -O0
, then I get no warnings at all which makes some sense because the warning messages explicitly mention inlining.
If these warnings are a direct result of inlining, and the functions are fine when not-inlined, then this seems like an issue with the compiler and not with tinydir
... ?
please check the return value of tinydir functions; they return 0 on non-errors. This should fix some of the warnings.
For example, if I use if (tinydir_open(&dir, path.c_str()) != 0) return files;
the warnings go away
In our repository idaholab/moose, we are getting the following warnings when compiling with gcc 11
Is this user error or is this something that can be fixed on your end? This is our user code