Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compilation Error with constexpr in etl::string_base::size() on ESP-WROVER-KIT (c++11) #892

Closed
JorgeHSantana opened this issue May 14, 2024 · 1 comment
Assignees
Labels

Comments

@JorgeHSantana
Copy link

JorgeHSantana commented May 14, 2024

Hello ETLCPP Team,

I am encountering a compilation error when using the etl::string in my project with ESP-WROVER-KIT. The error is related to the constexpr specification of the size() method in etl::string_base.

Error details:

In file included from .pio/libdeps/esp-wrover-kit/Embedded Template Library/include/etl/string.h:35:0,
                 from src/main.cpp:2:
.pio/libdeps/esp-wrover-kit/Embedded Template Library/include/etl/basic_string.h:176:29: error: enclosing class of constexpr non-static member function 'etl::string_base::size_type etl::string_base::size() const' is not a literal type
     ETL_CONSTEXPR size_type size() const
                             ^
.pio/libdeps/esp-wrover-kit/Embedded Template Library/include/etl/basic_string.h:166:9: note: 'etl::string_base' is not literal because:
   class string_base : public private_basic_string::string_base_statics<>
         ^
.pio/libdeps/esp-wrover-kit/Embedded Template Library/include/etl/basic_string.h:166:9: note:   'etl::string_base' has a non-trivial destructor
*** [.pio\build\esp-wrover-kit\src\main.cpp.o] Error 1

Description:
The issue seems to stem from the constexpr declaration of size() in a class (etl::string_base) that is not a literal type, primarily due to having a non-trivial destructor. According to the C++ standard, a class must be a literal type to contain constexpr methods.

Temporary Solution:
I was able to compile successfully by removing the ETL_CONSTEXPR macro from the size() method in basic_string.h (line 176):

size_type size() const

However, modifying the library code directly is not ideal for maintenance reasons.

Request:
Could you please look into this issue? Perhaps a revision in the use of constexpr in this context or an update to the library to support scenarios like this would be beneficial. Any guidance or fix would be greatly appreciated.

Thank you for your help and for maintaining such a useful library!

@jwellbelove jwellbelove self-assigned this May 15, 2024
@jwellbelove
Copy link
Contributor

Fixed in 20.38.15

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Development

No branches or pull requests

2 participants