From 8bfcb25f8ebfa4a60c3d07016adc11b9f37cc47e Mon Sep 17 00:00:00 2001
From: ckormanyos
Date: Sun, 4 Feb 2024 11:44:40 +0100
Subject: [PATCH 1/4] Add some more compile-time tests
---
math/softfloat/soft_double.h | 2 +-
test/test_soft_double_spot_values.cpp | 22 +++++++++++++++++-----
2 files changed, 18 insertions(+), 6 deletions(-)
diff --git a/math/softfloat/soft_double.h b/math/softfloat/soft_double.h
index 30b5cbd..2d24c2a 100644
--- a/math/softfloat/soft_double.h
+++ b/math/softfloat/soft_double.h
@@ -386,7 +386,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
};
}
- #if (defined(SOFT_DOUBLE_CONSTEXPR_BUILTIN_FLOATS) && (SOFT_DOUBLE_CONSTEXPR_BUILTIN_FLOATS == 0))
+ #if (defined(SOFT_DOUBLE_CONSTEXPR_BUILTIN_FLOATS) && (SOFT_DOUBLE_CONSTEXPR_BUILTIN_FLOATS == 0))
template::digits>::exact_unsigned_type>
diff --git a/test/test_soft_double_spot_values.cpp b/test/test_soft_double_spot_values.cpp
index fffe619..46bff5d 100644
--- a/test/test_soft_double_spot_values.cpp
+++ b/test/test_soft_double_spot_values.cpp
@@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////
-// Copyright Christopher Kormanyos 2022 - 2023. //
+// Copyright Christopher Kormanyos 2022 - 2024. //
// Distributed under the Boost Software License, //
// Version 1.0. (See accompanying file LICENSE_1_0.txt //
// or copy at http://www.boost.org/LICENSE_1_0.txt) //
@@ -86,10 +86,22 @@ namespace local
constexpr auto ctrl_d2 = ::math::softfloat::float64_t { static_cast(INT8_C(1)) } / static_cast(INT8_C(2));
constexpr auto ctrl_d3 = ::math::softfloat::float64_t { static_cast(INT8_C(5)) } / static_cast(INT8_C(8));
- const auto sd0 = ::math::softfloat::float64_t { f0 };
- const auto sd1 = ::math::softfloat::float64_t { f1 };
- const auto sd2 = ::math::softfloat::float64_t { f2 };
- const auto sd3 = ::math::softfloat::float64_t { f3 };
+ #if ((defined SOFT_DOUBLE_CONSTEXPR_BUILTIN_FLOATS) && (SOFT_DOUBLE_CONSTEXPR_BUILTIN_FLOATS == 1))
+ constexpr auto sd0 = ::math::softfloat::float64_t { f0 };
+ constexpr auto sd1 = ::math::softfloat::float64_t { f1 };
+ constexpr auto sd2 = ::math::softfloat::float64_t { f2 };
+ constexpr auto sd3 = ::math::softfloat::float64_t { f3 };
+
+ static_assert(sd0 == ctrl_d0, "Error: Initialization from constexpr-float does not properly work");
+ static_assert(sd1 == ctrl_d1, "Error: Initialization from constexpr-float does not properly work");
+ static_assert(sd2 == ctrl_d2, "Error: Initialization from constexpr-float does not properly work");
+ static_assert(sd3 == ctrl_d3, "Error: Initialization from constexpr-float does not properly work");
+ #else
+ constexpr auto sd0 = ::math::softfloat::float64_t { f0 };
+ constexpr auto sd1 = ::math::softfloat::float64_t { f1 };
+ constexpr auto sd2 = ::math::softfloat::float64_t { f2 };
+ constexpr auto sd3 = ::math::softfloat::float64_t { f3 };
+ #endif
auto result_construct_from_float_is_ok =
(
From 8710ef20a46fdcc24a6da005a90fb023a2a1fda4 Mon Sep 17 00:00:00 2001
From: ckormanyos
Date: Sun, 4 Feb 2024 11:48:57 +0100
Subject: [PATCH 2/4] Repair erroneous copy-paste typo
---
test/test_soft_double_spot_values.cpp | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/test/test_soft_double_spot_values.cpp b/test/test_soft_double_spot_values.cpp
index 46bff5d..35eb87e 100644
--- a/test/test_soft_double_spot_values.cpp
+++ b/test/test_soft_double_spot_values.cpp
@@ -97,10 +97,10 @@ namespace local
static_assert(sd2 == ctrl_d2, "Error: Initialization from constexpr-float does not properly work");
static_assert(sd3 == ctrl_d3, "Error: Initialization from constexpr-float does not properly work");
#else
- constexpr auto sd0 = ::math::softfloat::float64_t { f0 };
- constexpr auto sd1 = ::math::softfloat::float64_t { f1 };
- constexpr auto sd2 = ::math::softfloat::float64_t { f2 };
- constexpr auto sd3 = ::math::softfloat::float64_t { f3 };
+ const auto sd0 = ::math::softfloat::float64_t { f0 };
+ const auto sd1 = ::math::softfloat::float64_t { f1 };
+ const auto sd2 = ::math::softfloat::float64_t { f2 };
+ const auto sd3 = ::math::softfloat::float64_t { f3 };
#endif
auto result_construct_from_float_is_ok =
From efd04c32e2f693ef5b84f36b5d4f762b8fdcd41b Mon Sep 17 00:00:00 2001
From: ckormanyos
Date: Sun, 4 Feb 2024 12:02:47 +0100
Subject: [PATCH 3/4] Update CI checkout actions
---
.github/workflows/soft_double.yml | 32 +++++++++++------------
.github/workflows/soft_double_codecov.yml | 2 +-
.github/workflows/soft_double_sonar.yml | 2 +-
3 files changed, 18 insertions(+), 18 deletions(-)
diff --git a/.github/workflows/soft_double.yml b/.github/workflows/soft_double.yml
index 81435bd..225c661 100644
--- a/.github/workflows/soft_double.yml
+++ b/.github/workflows/soft_double.yml
@@ -23,7 +23,7 @@ jobs:
compiler: [ g++-11, clang++ ]
standard: [ c++14, c++17, c++20 ]
steps:
- - uses: actions/checkout@v3
+ - uses: actions/checkout@v4
with:
fetch-depth: '0'
- name: update-tools
@@ -50,7 +50,7 @@ jobs:
runs-on: ubuntu-latest
container: ${{matrix.container}}
steps:
- - uses: actions/checkout@v3
+ - uses: actions/checkout@v4
- name: create build directory
run: mkdir $GITHUB_WORKSPACE/build
- name: build
@@ -70,7 +70,7 @@ jobs:
cmake-windows:
runs-on: windows-latest
steps:
- - uses: actions/checkout@v3
+ - uses: actions/checkout@v4
- name: create build directory
run: mkdir ${{runner.workspace}}/build
- name: build
@@ -93,7 +93,7 @@ jobs:
standard: [ c++20 ]
compiler: [ g++, clang++ ]
steps:
- - uses: actions/checkout@v3
+ - uses: actions/checkout@v4
with:
fetch-depth: '0'
- name: update-tools
@@ -121,7 +121,7 @@ jobs:
compiler: [ g++-12, clang++-14 ]
standard: [ c++14, c++17, c++20 ]
steps:
- - uses: actions/checkout@v3
+ - uses: actions/checkout@v4
with:
fetch-depth: '0'
- name: update-tools
@@ -144,7 +144,7 @@ jobs:
compiler: [ g++ ]
standard: [ c++14, c++17, c++2a ]
steps:
- - uses: actions/checkout@v3
+ - uses: actions/checkout@v4
with:
fetch-depth: '0'
- name: mingw-winhost-x64
@@ -165,7 +165,7 @@ jobs:
compiler: [ g++-11, clang++ ]
standard: [ c++14, c++17, c++20 ]
steps:
- - uses: actions/checkout@v3
+ - uses: actions/checkout@v4
with:
fetch-depth: '0'
- name: update-tools
@@ -188,7 +188,7 @@ jobs:
compiler: [ g++-11, clang++ ]
standard: [ c++14, c++17, c++20 ]
steps:
- - uses: actions/checkout@v3
+ - uses: actions/checkout@v4
with:
fetch-depth: '0'
- name: update-tools
@@ -211,7 +211,7 @@ jobs:
compiler: [ g++, clang++ ]
standard: [ c++14, c++17, c++20 ]
steps:
- - uses: actions/checkout@v3
+ - uses: actions/checkout@v4
with:
fetch-depth: '0'
- name: apple-gcc-clang-native
@@ -224,7 +224,7 @@ jobs:
msvc-release-x64:
runs-on: windows-latest
steps:
- - uses: actions/checkout@v3
+ - uses: actions/checkout@v4
- uses: ilammy/msvc-dev-cmd@v1
with:
toolset: 14.2
@@ -238,10 +238,10 @@ jobs:
msvc-release-x64-vs2022:
runs-on: windows-latest
steps:
- - uses: actions/checkout@v3
+ - uses: actions/checkout@v4
with:
fetch-depth: '0'
- - uses: actions/checkout@v3
+ - uses: actions/checkout@v4
- uses: ilammy/msvc-dev-cmd@v1
with:
toolset: 14.3
@@ -262,7 +262,7 @@ jobs:
matrix:
standard: [ c++14 ]
steps:
- - uses: actions/checkout@v3
+ - uses: actions/checkout@v4
with:
fetch-depth: '0'
- name: update-tools
@@ -286,7 +286,7 @@ jobs:
ls -la bin/example010_hypergeometric_2f1.elf bin/example010_hypergeometric_2f1.map bin/example010_hypergeometric_2f1.hex
working-directory: ./
gcc-arm-none-eabi:
- runs-on: ubuntu-22.04
+ runs-on: ubuntu-latest
defaults:
run:
shell: bash
@@ -295,7 +295,7 @@ jobs:
matrix:
standard: [ c++14, c++17, c++2a ]
steps:
- - uses: actions/checkout@v3
+ - uses: actions/checkout@v4
with:
fetch-depth: '0'
- name: update-tools
@@ -337,7 +337,7 @@ jobs:
compiler: [ g++, clang++ ]
suite: [ cyl_bessel_j ]
steps:
- - uses: actions/checkout@v3
+ - uses: actions/checkout@v4
with:
fetch-depth: '0'
- name: clone-submods-bootstrap-headers-boost-develop
diff --git a/.github/workflows/soft_double_codecov.yml b/.github/workflows/soft_double_codecov.yml
index e6c343d..2ea0dfb 100644
--- a/.github/workflows/soft_double_codecov.yml
+++ b/.github/workflows/soft_double_codecov.yml
@@ -24,7 +24,7 @@ jobs:
standard: [ c++14 ]
compiler: [ g++ ]
steps:
- - uses: actions/checkout@v3
+ - uses: actions/checkout@v4
with:
fetch-depth: '0'
- name: update-tools
diff --git a/.github/workflows/soft_double_sonar.yml b/.github/workflows/soft_double_sonar.yml
index 9f93161..2f6bbd1 100644
--- a/.github/workflows/soft_double_sonar.yml
+++ b/.github/workflows/soft_double_sonar.yml
@@ -21,7 +21,7 @@ jobs:
SONAR_SERVER_URL: "https://sonarcloud.io"
BUILD_WRAPPER_OUT_DIR: build_wrapper_output_directory # Directory where build-wrapper output will be placed
steps:
- - uses: actions/checkout@v3
+ - uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up JDK 17
From eaf00a0aa4201103cd71b59389819f79fec0ec6b Mon Sep 17 00:00:00 2001
From: ckormanyos
Date: Sun, 4 Feb 2024 12:18:24 +0100
Subject: [PATCH 4/4] Update docs and syntax
---
README.md | 19 +++++++++----------
examples/example012_exercise_constexpr.cpp | 2 +-
2 files changed, 10 insertions(+), 11 deletions(-)
diff --git a/README.md b/README.md
index d0e4b1e..21eaa5a 100644
--- a/README.md
+++ b/README.md
@@ -18,7 +18,7 @@ soft_double
-
+
@@ -165,7 +165,7 @@ how to use soft_double.
- ![`example011_trig_trapezoid_integral.cpp`](./examples/example011_trig_trapezoid_integral.cpp) uses trapezoid integration with an integral representation involving locally-written trigonometric sine and cosine functions to compute several cylindrical Bessel function values.
- ![`example012_exercise_constexpr.cpp`](./examples/example012_exercise_constexpr.cpp) verifies that C++20 `constexpr`-ness works properly for both rudimentary assignment-operation as well as an elementary square root function.
-## C++14, 17, 20 `constexpr` support
+## C++20 `constexpr` support
When using C++20, `soft_double` supports compile-time
`constexpr` construction and evaluation of results
@@ -212,14 +212,13 @@ int main()
}
```
-`constexpr`-_ness_ of `soft_double` has been checked on GCC 10 and up, clang 10 and up
-(with `-std=c++20`) and VC 14.2 (with `/std:c++latest`),
-also for various embedded compilers such as `avr-gcc` 10 and up,
-`arm-non-eabi-gcc` 10 and up, and more. In addition,
-less modern compiler versions in addition to some other compilers
-having standards such as C++14, 17, 2a have also been checked
-for `constexpr` usage of `soft_double`. If you have an older
-compiler, you might have to check the compiler's
+`constexpr`-ness of `soft_double` has been checked on GCC, clang
+(with `-std=c++20` and beyond) and VC 14.2 and higher (with `/std:c++latest`),
+also for various embedded compilers such as `avr-gcc` 11 and up,
+`arm-non-eabi-gcc` 11 and up, and more.
+In addition, less modern compiler versions have been sporadically
+(not exhaustively) checked for `constexpr` usage of `soft_double`.
+If you have an older compiler, you might have to check the compiler's
ability to obtain the entire benefit of `constexpr` with `soft_double`.
In [issue 110](https://github.com/ckormanyos/soft_double/issues/110),
diff --git a/examples/example012_exercise_constexpr.cpp b/examples/example012_exercise_constexpr.cpp
index 982250b..573a9a2 100644
--- a/examples/example012_exercise_constexpr.cpp
+++ b/examples/example012_exercise_constexpr.cpp
@@ -56,7 +56,7 @@ auto math::softfloat::example012_exercise_constexpr() -> bool
#include
#include
-int main()
+auto main() -> int
{
const bool result_is_ok = math::softfloat::example012_exercise_constexpr();