Skip to content
Snippets Groups Projects
Commit db5a7362 authored by Ben Cumming's avatar Ben Cumming Committed by Sam Yates
Browse files

Bug/issue#97 (#102)

This addresses all of the compiler warnings and errors for xlc when compiled at -O0. There are still compiler bugs when compiling with higher optimization levels, however they are more challenging.

* Ignore the incorrect `-Wno-missing-braces` warnings (similarly to Clang).
* Remove `-qhalt=e flag` inserted by CMake.
* Remove redundant comparison of char to EOF in lexer.
* The XLC compiler was crashing inexplicably on one call of the following method:
   ```void run(..., const std::vector<float>& excl={}) {...}```
  This was fixed by not having a default value for the last argument.
* Add some curly braces to silence warning for dangling else.

fixes #97
parent 62b57271
No related branches found
No related tags found
No related merge requests found
...@@ -5,6 +5,17 @@ set(CXXOPT_PTHREAD "-pthread") ...@@ -5,6 +5,17 @@ set(CXXOPT_PTHREAD "-pthread")
set(CXXOPT_CXX11 "-std=c++11") set(CXXOPT_CXX11 "-std=c++11")
set(CXXOPT_WALL "-Wall") set(CXXOPT_WALL "-Wall")
if(${CMAKE_CXX_COMPILER_ID} MATCHES "XL")
# Disable 'missing-braces' warning: this will inappropriately
# flag initializations such as
# std::array<int,3> a={1,2,3};
set(CXXOPT_WALL "${CXXOPT_WALL} -Wno-missing-braces")
# CMake, bless its soul, likes to insert this unsupported flag. Hilarity ensues.
string(REPLACE "-qhalt=e" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
endif()
if(${CMAKE_CXX_COMPILER_ID} MATCHES "Clang") if(${CMAKE_CXX_COMPILER_ID} MATCHES "Clang")
# Disable 'missing-braces' warning: this will inappropriately # Disable 'missing-braces' warning: this will inappropriately
# flag initializations such as # flag initializations such as
......
...@@ -23,7 +23,7 @@ inline bool is_whitespace(char c) { ...@@ -23,7 +23,7 @@ inline bool is_whitespace(char c) {
return (c==' ' || c=='\t' || c=='\v' || c=='\f'); return (c==' ' || c=='\t' || c=='\v' || c=='\f');
} }
inline bool is_eof(char c) { inline bool is_eof(char c) {
return (c==0 || c==EOF); return (c==0);
} }
inline bool is_operator(char c) { inline bool is_operator(char c) {
return (c=='+' || c=='-' || c=='*' || c=='/' || c=='^' || c=='\''); return (c=='+' || c=='-' || c=='*' || c=='/' || c=='^' || c=='\'');
...@@ -47,7 +47,6 @@ Token Lexer::parse() { ...@@ -47,7 +47,6 @@ Token Lexer::parse() {
switch(*current_) { switch(*current_) {
// end of file // end of file
case 0 : // end of string case 0 : // end of string
case EOF : // end of file
t.spelling = "eof"; t.spelling = "eof";
t.type = tok::eof; t.type = tok::eof;
return t; return t;
......
...@@ -51,8 +51,8 @@ void serial_destroy( RandomAccessIterator zs, RandomAccessIterator ze ) { ...@@ -51,8 +51,8 @@ void serial_destroy( RandomAccessIterator zs, RandomAccessIterator ze ) {
template<class RandomAccessIterator1, class RandomAccessIterator2, class RandomAccessIterator3, class Compare> template<class RandomAccessIterator1, class RandomAccessIterator2, class RandomAccessIterator3, class Compare>
void serial_move_merge( RandomAccessIterator1 xs, RandomAccessIterator1 xe, RandomAccessIterator2 ys, RandomAccessIterator2 ye, RandomAccessIterator3 zs, Compare comp ) { void serial_move_merge( RandomAccessIterator1 xs, RandomAccessIterator1 xe, RandomAccessIterator2 ys, RandomAccessIterator2 ye, RandomAccessIterator3 zs, Compare comp ) {
if( xs!=xe ) { if( xs!=xe ) {
if( ys!=ye ) if( ys!=ye ) {
for(;;) for(;;) {
if( comp(*ys,*xs) ) { if( comp(*ys,*xs) ) {
*zs = std::move(*ys); *zs = std::move(*ys);
++zs; ++zs;
...@@ -62,6 +62,8 @@ void serial_move_merge( RandomAccessIterator1 xs, RandomAccessIterator1 xe, Rand ...@@ -62,6 +62,8 @@ void serial_move_merge( RandomAccessIterator1 xs, RandomAccessIterator1 xe, Rand
++zs; ++zs;
if( ++xs==xe ) goto movey; if( ++xs==xe ) goto movey;
} }
}
}
ys = xs; ys = xs;
ye = xe; ye = xe;
} }
......
...@@ -151,6 +151,7 @@ TEST(uninitialized,apply) { ...@@ -151,6 +151,7 @@ TEST(uninitialized,apply) {
const uninitialized<int> ud(ua); const uninitialized<int> ud(ua);
r=ud.apply(A); r=ud.apply(A);
EXPECT_EQ(12,ua.cref()); EXPECT_EQ(12,ua.cref());
EXPECT_EQ(12,ud.cref()); EXPECT_EQ(12,ud.cref());
EXPECT_EQ(13,r); EXPECT_EQ(13,r);
......
...@@ -71,7 +71,7 @@ public: ...@@ -71,7 +71,7 @@ public:
} }
template <typename Model> template <typename Model>
void run(Model& m, Param p, float t_end, float dt, const std::vector<float>& excl={}) { void run(Model& m, Param p, float t_end, float dt, const std::vector<float>& excl) {
// reset samplers and attach to probe locations // reset samplers and attach to probe locations
for (auto& se: cell_samplers_) { for (auto& se: cell_samplers_) {
se.sampler.reset(); se.sampler.reset();
......
...@@ -46,7 +46,7 @@ void validate_soma() { ...@@ -46,7 +46,7 @@ void validate_soma() {
model.reset(); model.reset();
float dt = float(1./oo_dt); float dt = float(1./oo_dt);
runner.run(model, dt, t_end, dt); runner.run(model, dt, t_end, dt, {});
} }
} }
end: end:
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment