LoopPerfect / neither

Either and Maybe monads for better error-handling in C++ ↔️
MIT License
249 stars 18 forks source link

Uniform initialization causes problems with gcc #22

Closed WojciechMigda closed 5 years ago

WojciechMigda commented 5 years ago

Uniform initialization (curly braces initialization) is being used in either.hpp, and while there should be nothing wrong with that some compilers do not handle this well.

For instance, uniform initialization causes problems with nlohmann's json library compiled with gcc, as backed with this issue: https://github.com/nlohmann/json/issues/985

So, using neither with gcc and json objects causes the latter being modified.

As an excercise I have removed uniform initialization from either.hpp and after that Either wrapped around json I was playing with worked as expected.

nikhedonia commented 5 years ago

Thanks, that's interesting! Does it work in gcc 8?

As an exercise I have removed uniform initialization from either.hpp

Can you make a PR ?

WojciechMigda commented 5 years ago

Hi, g++ 8.1 on coliru shows that g++ is stil doing universal initialization wrong: http://coliru.stacked-crooked.com/a/81b996265763eb16 I will follow up with a PR. Thanks!

njlr commented 5 years ago

Merged. Please close out as appropriate.

WojciechMigda commented 5 years ago

Thanks!