"error: '__pstr__' declared 'static' in 'constexpr' function" when building in Arduino for ESP8266 (GCC gcc10.3)
I tried including expected.hpp (latest 0.8.0) like this:
#define nsel_CPLUSPLUS 199711L #define nsel_CONFIG_NO_EXCEPTIONS 1 #include "3rdparty/nonstd/expected.hpp"
but get built errors:
In file included from /home/vincas/.arduino15/packages/esp8266/tools/xtensa-lx106-elf-gcc/3.1.0-gcc10.3-e5f9fec/xtensa-lx106-elf/include/assert.h:10,
from /home/vincas/.arduino15/packages/esp8266/tools/xtensa-lx106-elf-gcc/3.1.0-gcc10.3-e5f9fec/xtensa-lx106-elf/include/c++/10.3.0/cassert:44,
from /somewhere/3rdparty/nonstd/expected.hpp:255,
from /somewhere/sha256.hpp:3,
from /somewhere/sha256.cpp:1:
/somewhere/3rdparty/nonstd/expected.hpp: In member function 'constexpr const value_type* nonstd::expected_lite::expected<T, E>::operator->() const':
/somewhere/3rdparty/nonstd/expected.hpp:2158:16: error: '__pstr__' declared 'static' in 'constexpr' function
2158 | return assert( has_value() ), contained.value_ptr();
| ^~~~~~
/somewhere/3rdparty/nonstd/expected.hpp:2158:16: error: '__pstr__' declared 'static' in 'constexpr' function
2158 | return assert( has_value() ), contained.value_ptr();
| ^~~~~~
/somewhere/3rdparty/nonstd/expected.hpp: In member function 'constexpr const value_type& nonstd::expected_lite::expected<T, E>::operator*() const &':
/somewhere/3rdparty/nonstd/expected.hpp:2168:16: error: '__pstr__' declared 'static' in 'constexpr' function
2168 | return assert( has_value() ), contained.value();
| ^~~~~~
/somewhere/3rdparty/nonstd/expected.hpp:2168:16: error: '__pstr__' declared 'static' in 'constexpr' function
2168 | return assert( has_value() ), contained.value();
| ^~~~~~
/somewhere/3rdparty/nonstd/expected.hpp: In member function 'constexpr const value_type&& nonstd::expected_lite::expected<T, E>::operator*() const &&':
/somewhere/3rdparty/nonstd/expected.hpp:2180:29: error: '__pstr__' declared 'static' in 'constexpr' function
2180 | return std::move( ( assert( has_value() ), contained.value() ) );
| ^~~~~~
/somewhere/3rdparty/nonstd/expected.hpp:2180:29: error: '__pstr__' declared 'static' in 'constexpr' function
2180 | return std::move( ( assert( has_value() ), contained.value() ) );
| ^~~~~~
/somewhere/3rdparty/nonstd/expected.hpp: In member function 'constexpr const error_type& nonstd::expected_lite::expected<T, E>::error() const &':
/somewhere/3rdparty/nonstd/expected.hpp:2237:16: error: '__pstr__' declared 'static' in 'constexpr' function
2237 | return assert( ! has_value() ), contained.error();
| ^~~~~~
/somewhere/3rdparty/nonstd/expected.hpp:2237:16: error: '__pstr__' declared 'static' in 'constexpr' function
2237 | return assert( ! has_value() ), contained.error();
| ^~~~~~
/somewhere/3rdparty/nonstd/expected.hpp: In member function 'constexpr const error_type&& nonstd::expected_lite::expected<T, E>::error() const &&':
/somewhere/3rdparty/nonstd/expected.hpp:2249:29: error: '__pstr__' declared 'static' in 'constexpr' function
2249 | return std::move( ( assert( ! has_value() ), contained.error() ) );
| ^~~~~~
/somewhere/3rdparty/nonstd/expected.hpp:2249:29: error: '__pstr__' declared 'static' in 'constexpr' function
2249 | return std::move( ( assert( ! has_value() ), contained.error() ) );
| ^~~~~~
/somewhere/3rdparty/nonstd/expected.hpp: In member function 'constexpr const error_type& nonstd::expected_lite::expected<void, E>::error() const &':
/somewhere/3rdparty/nonstd/expected.hpp:2819:16: error: '__pstr__' declared 'static' in 'constexpr' function
2819 | return assert( ! has_value() ), contained.error();
| ^~~~~~
/somewhere/3rdparty/nonstd/expected.hpp:2819:16: error: '__pstr__' declared 'static' in 'constexpr' function
2819 | return assert( ! has_value() ), contained.error();
| ^~~~~~
/somewhere/3rdparty/nonstd/expected.hpp: In member function 'constexpr const error_type&& nonstd::expected_lite::expected<void, E>::error() const &&':
/somewhere/3rdparty/nonstd/expected.hpp:2831:29: error: '__pstr__' declared 'static' in 'constexpr' function
2831 | return std::move( ( assert( ! has_value() ), contained.error() ) );
| ^~~~~~
/somewhere/3rdparty/nonstd/expected.hpp:2831:29: error: '__pstr__' declared 'static' in 'constexpr' function
2831 | return std::move( ( assert( ! has_value() ), contained.error() ) );
|
Any ideas how to workaround that? Well, it's kinda just experiment "for fun", it's nice to use some latest C++ features on "bare metal", but I guess some compiler features are missing?
I can use costepxr, [[nodiscard]], but I guess some other feature missing?
P.S. to reproduce:
- Download Arduino 2.3.3.
- Add
http://arduino.esp8266.com/stable/package_esp8266com_index.jsoninPreferences -> Additional boards manager URLs. - Install
esp32 by Espressif SystemsinTools -> Board -> Boards Manager.... - Select
LOLIN(WeMos) D1 R1inTools -> Board -> esp8266 - Paste
expected.hppin same folder where Arduino Sketch (.ino) is and#includeit.
Like the: Well, it's kinda just experiment "for fun", it's nice to use some latest C++ features on "bare metal" :)
To me, the implementation of assert() seems to collide with constexpr.
Perhaps you can try and see what compiling without assertions (defining NDEBUG) results in [1] ?
I do appreciate the steps to reproduce you provide, however it may be a bit much to perform these myself at the moment.
Perhaps you can try and see what compiling without assertions (defining NDEBUG) results in [1] ?
I've did this:
#define NDEBUG
#include "src/3rdparty/expected.hpp"
And it builds!
Thanks!