Comments (14)
We can do that specifically on NJOY21 I think by doing this in NJOY21.hpp:
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
#include "lipservice.hpp"
#pragma GCC diagnostic pop
I wonder if that will be sufficient or if we need to wrap the pragmas around more of the code in NJOY21.hpp.
from njoy21.
Note, this is likely an issue in the component lipservice than in NJOY21 directly.
from njoy21.
I think this is a bug in GCC. The code that GCC points to as being uninitialized is here:
class Card12{
public:
using Aw = POWR::Lib3::Card9::Aw;
#include "lipservice/POWR/Lib3/Card12/Temp.hpp"
#include "lipservice/POWR/Lib3/Card12/Fpa.hpp"
Argument< Aw > aw;
Argument< Temp > temp;
Argument< Fpa > fpa;
template< typename Istream >
Card12( Istream& is, const size_t ngnd )
try:
aw( argument::extract< POWR::Lib3::Card12::Aw >( is ) ),
temp( argument::extract< POWR::Lib3::Card12::Temp >( is ) ),
fpa( argument::extract< POWR::Lib3::Card12::Fpa >( is, ngnd ) )
{
Card::clear( is );
}
catch( std::exception& e ){
Log::info( "Trouble reading Card 12." );
throw e;
}
};
You can see that aw
, temp
, and fpa
are all initialized in the constructor.
By the way, when I use GCC version 9.2.0, I get a different uninitialized error.
from njoy21.
I got uninitialized errors with both 9.2 and 8.3 yesterday, although I didn't pay attention to if they pointed to the same spots or not.
These "may be uninitialized" errors are actually warnings converted to errors by using strict compiling. We can probably add some compiler flags to GCC to ignore these warnings if we don't find a better solution.
I'll keep looking to see if I can figure anything else out.
from njoy21.
from njoy21.
We intentionally turned warnings into errors with the hopes that we get better code. I think in general it's a good idea.
We can rethink this policy, or turn off some warnings, or even do it differently from one compiler to another.
from njoy21.
Here's a good read for some others with similar code throwing the -Wmaybe-uninitialized
warning. I particularly liked the comment "maybe-uninitialized includes maybe for a reason".
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80635
This at least relates to the warning being around some std::optional
, which is where GCC 9.2 and 8.3 seem to throw the warning. The example @jlconlin included above at least doesn't obviously invoke std::optional
, but I suspect it's still the same underlying issue.
I am leaning toward suppressing the -Wmaybe-uninitialized
warnings with GCC compiler flags at this point, personally.
from njoy21.
Assuming this works, I'm fine with this change. Fortunately, lipservice isn't used by other components.
The other option is to do this in CMake, and attach is specifically to the release build option. That way, warnings would still appear if compiled with debug options of blank or debug.
from njoy21.
We should investigate this further before trying to switch off the error to remove it. Once we start doing this, it'll be always easier to remove the error instead of addressing it. I have no objection doing this on code that we did not write (e.g. we actually have had to do this with Eigen) but we own this code so we should do more to try to figure it out first.
We could assign the values a default initialisation value when declaring them.
struct test {
int a = 0;
};
from njoy21.
@whaeck I aree with your sentiment. However, GCC seems to be inconsistent here. It fails in different spots using different versions of GCC. It does not fail when compiling lipservice on its own. Since lip service is tested independently (and this warning/error doesn't come up), I'm comfortable turning off the warning in NJOY21.
from njoy21.
I was typing up a similar response to @whaeck as @jlconlin just posted. I don't want to waste a lot of time chasing down what definitely seems to be a GCC bug, particularly with it hitting inconsistently. Redundant declarations can probably avoid this warning, but I'm worried that we'd need a whole lot of these. And lipservice isn't the focus of development now anyway.
from njoy21.
This problem has cropped up again.
I tried to compile with GCC version 9.2.0 and got this error:
$ cmake -D CMAKE_BUILD_TYPE=Release ..
...
$ make
...
[ 86%] Building CXX object CMakeFiles/njoy21.dir/src/main.cpp.o
In file included from /Users/jlconlin/NJOY21/Code/NJOY21/bin-llvm/_deps/lipservice-src/src/lipservice/DTFR/Card8.hpp:3,
from /Users/jlconlin/NJOY21/Code/NJOY21/bin-llvm/_deps/lipservice-src/src/lipservice/DTFR.hpp:11,
from /Users/jlconlin/NJOY21/Code/NJOY21/bin-llvm/_deps/lipservice-src/src/lipservice.hpp:42,
from /Users/jlconlin/NJOY21/Code/NJOY21/src/njoy21.hpp:21,
from /Users/jlconlin/NJOY21/Code/NJOY21/src/main.cpp:1:
/Users/jlconlin/NJOY21/Code/NJOY21/bin-llvm/_deps/lipservice-src/src/lipservice/DTFR/Card8/Hisnam.hpp: In function 'auto njoy::njoy21::lipservice::argument::extract(njoy::njoy21::lipservice::iRecordStream<Char>&, Args&& ...) [with Policy = njoy::njoy21::lipservice::DTFR::Card8::Hisnam; Char = char; Args = {}]':
/Users/jlconlin/NJOY21/Code/NJOY21/bin-llvm/_deps/lipservice-src/src/lipservice/DTFR/Card8/Hisnam.hpp:15:56: error: '*((void*)<anonymous>+8)' may be used uninitialized in this function [-Werror=maybe-uninitialized]
15 | static bool verify( Value_t str ){ return str->length() <= 6; }
| ~~~~~~~~~~~^~
In file included from /Users/jlconlin/NJOY21/Code/NJOY21/bin-llvm/_deps/lipservice-src/src/lipservice/LEAPR/Card20.hpp:3,
from /Users/jlconlin/NJOY21/Code/NJOY21/bin-llvm/_deps/lipservice-src/src/lipservice/LEAPR.hpp:22,
from /Users/jlconlin/NJOY21/Code/NJOY21/bin-llvm/_deps/lipservice-src/src/lipservice.hpp:45,
from /Users/jlconlin/NJOY21/Code/NJOY21/src/njoy21.hpp:21,
from /Users/jlconlin/NJOY21/Code/NJOY21/src/main.cpp:1:
/Users/jlconlin/NJOY21/Code/NJOY21/bin-llvm/_deps/lipservice-src/src/lipservice/LEAPR/Card20/Comment.hpp: In function 'auto njoy::njoy21::lipservice::argument::extract(njoy::njoy21::lipservice::iRecordStream<Char>&, Args&& ...) [with Policy = njoy::njoy21::lipservice::LEAPR::Card20::Comment; Char = char; Args = {}]':
/Users/jlconlin/NJOY21/Code/NJOY21/bin-llvm/_deps/lipservice-src/src/lipservice/LEAPR/Card20/Comment.hpp:16:56: error: '*((void*)<anonymous>+8)' may be used uninitialized in this function [-Werror=maybe-uninitialized]
16 | static bool verify( Value_t str ){ return str->length() <= 66; }
| ~~~~~~~~~~~^~
I removed the pragma
code in version 1.2.0, and that seems to cause GCC to fail to compile in Release mode.
from njoy21.
I think this is a bug in GCC. The code that GCC points to as being uninitialized is here:
class Card12{ public: using Aw = POWR::Lib3::Card9::Aw; #include "lipservice/POWR/Lib3/Card12/Temp.hpp" #include "lipservice/POWR/Lib3/Card12/Fpa.hpp" Argument< Aw > aw; Argument< Temp > temp; Argument< Fpa > fpa; template< typename Istream > Card12( Istream& is, const size_t ngnd ) try: aw( argument::extract< POWR::Lib3::Card12::Aw >( is ) ), temp( argument::extract< POWR::Lib3::Card12::Temp >( is ) ), fpa( argument::extract< POWR::Lib3::Card12::Fpa >( is, ngnd ) ) { Card::clear( is ); } catch( std::exception& e ){ Log::info( "Trouble reading Card 12." ); throw e; } };You can see that
aw
,temp
, andfpa
are all initialized in the constructor.By the way, when I use GCC version 9.2.0, I get a different uninitialized error.
Just a quick thought, looking at this for the first time. (Maybe you're way ahead of me on this.) Because aw, temp, and fpa are initialized in a "try", the compiler might be thinking, "well, if an exception is thrown while trying, some or all of those might not have been initialized yet." Hence the warning/error.
Of course, anything - anywhere - might not be initialized as it appears to be initialized, if an exception is thrown. I just wonder if the compiler makes an extra fuss about it here, in this (not too commonly used) variation of a try. (During initialization in a constructor.)
I haven't looked closely at the code, but wonder if those could be moved to the constructor's body, rather than initialized in the customary constructor way, without breaking anything. Would the diagnostic go away?
from njoy21.
@staleyLANL Thanks for looking in to this. We have this construct throughout lipservice; if we fix it for this particular case, it would crop up somewhere else.
I don't think we can move the initialization to the body of the constructor because the Argument<...>
class doesn't have default constructors (I think).
from njoy21.
Related Issues (20)
- install in Anaconda environment HOT 1
- Processing of MF10 Multi-isotope entries HOT 4
- Segmentation fault (core dumped) with ACER HOT 1
- Beginners quide, FAQ, examples? HOT 4
- Memory consumption at 94% HOT 3
- Segmentation fault in compiling NJOY on Conda enviroment HOT 3
- Segmentation fault when attempting to make (Mac M1) HOT 1
- tape20 and input files for test2 HOT 1
- Can't build v1.1.0 using given instructions HOT 2
- Installation problem HOT 2
- Build fails with deprecated is_literal_type in hana dependency HOT 6
- Build fails with `error: size of array ‘altStackMem’ is not an integral constant-expression` HOT 1
- Comparing two TSL HOT 3
- LEAPR S(alpha,beta) and rho phonon frequency spectrum HOT 2
- Read COVR matrices HOT 2
- NJOY21 installation error HOT 4
- Runtime error: end of file HOT 4
- Error when running ACER with 'suff' equal to '.07' HOT 1
- catch-adapter issue? HOT 1
- Instalation problem HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from njoy21.