Bug 437890 - kseexpr FTBFS with GCC 11
Summary: kseexpr FTBFS with GCC 11
Status: RESOLVED FIXED
Alias: None
Product: SeExpr
Classification: Frameworks and Libraries
Component: General (other bugs)
Version First Reported In: unspecified
Platform: Compiled Sources Linux
: NOR normal
Target Milestone: ---
Assignee: amyspark
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-05-31 06:35 UTC by Christophe Marin
Modified: 2021-06-01 23:58 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Christophe Marin 2021-05-31 06:35:32 UTC
We seeing a couple build failures with GCC 11:

#1
/home/abuild/rpmbuild/BUILD/kseexpr-4.0.1.0/src/KSeExpr/Utils.cpp:13:52: error: 'strlen' is not a member of 'std'; did you mean 'mbrlen'?

This file needs a cstring include

#2
[   43s] /home/abuild/rpmbuild/BUILD/kseexpr-4.0.1.0/src/KSeExpr/Utils.cpp: In function 'double_t KSeExpr::Utils::atof(const char*)':
[   43s] /home/abuild/rpmbuild/BUILD/kseexpr-4.0.1.0/src/KSeExpr/Utils.cpp:14:10: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
[   43s]    14 |     auto [p, ec] = std::from_chars(num, num + std::strlen(num), v);
[   43s]       |          ^
[   43s] /home/abuild/rpmbuild/BUILD/kseexpr-4.0.1.0/src/KSeExpr/Utils.cpp: In function 'double_t KSeExpr::Utils::atof(const string&)':
[   43s] /home/abuild/rpmbuild/BUILD/kseexpr-4.0.1.0/src/KSeExpr/Utils.cpp:25:10: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
[   43s]    25 |     auto [p, ec] = std::from_chars(val.data(), val.data() + val.size(), v);
[   43s]       |          ^
[   43s] /home/abuild/rpmbuild/BUILD/kseexpr-4.0.1.0/src/KSeExpr/Utils.cpp:25:36: error: 'val' was not declared in this scope
[   43s]    25 |     auto [p, ec] = std::from_chars(val.data(), val.data() + val.size(), v);
[   43s]       |                                    ^~~
Comment 1 Christophe Marin 2021-05-31 08:01:35 UTC
FTR, KSeExpr_HAVE_CHARCONV_WITH_DOUBLES is defined with GCC 11 but not with GCC 10 or clang. This code may have always been broken
Comment 2 amyspark 2021-05-31 16:59:15 UTC
Confirming, I'll try and get my hands on GCC11. You're indeed correct, because this codepath was designed for the case where we could use C++17 (we're stuck in 14 in Krita).
Comment 3 amyspark 2021-06-01 20:43:56 UTC
The strlen part is clearly a bug on my end. The remaining are a "feature" of both GCC and glibc. If my tests are correct, <charconv> should *not* be available if the C++ standard is less than 17 (as in our case), see https://en.cppreference.com/w/cpp/header/charconv . This should also fail as soon as it tries to build the structured bindings.
Comment 4 Christophe Marin 2021-06-01 20:56:28 UTC
> if the C++ standard is less than 17 (as in our case)

That's not the case afaics. If you want to enforce CXX 14, you need `set(CMAKE_CXX_STANDARD_REQUIRED ON)` after `set(CMAKE_CXX_STANDARD 14)` in the main CMakeLists.txt
Comment 5 Christophe Marin 2021-06-01 21:01:42 UTC
Note that it won't affect the charconv test in src/KSeExpr/CMakeLists.txt. If you don't want it, just comment out lines 60 to 71
Comment 6 amyspark 2021-06-01 23:58:11 UTC
Git commit 1e8e6c8da1e22c4d32e50d8999705fd370824736 by L. E. Segovia.
Committed on 01/06/2021 at 23:35.
Pushed by lsegovia into branch 'master'.

Fix charconv support with MSVC/GCC11

M  +3    -2    src/KSeExpr/Utils.cpp

https://invent.kde.org/graphics/kseexpr/commit/1e8e6c8da1e22c4d32e50d8999705fd370824736