Conversation
This caused INT_CASE to be always false
| { | ||
| typedef std::pair<typename C::first_argument_type, Value> | ||
| typedef K first_argument_type; | ||
| typedef std::pair<first_argument_type, Value> |
There was a problem hiding this comment.
first_argument is removed in CXX23 so we need an additional template argument, the rest of the code is adjusted, user code is not affected as far as I see
| typedef typename A::reference reference; | ||
| typedef typename A::const_reference const_reference; | ||
| typedef typename A::value_type& reference; | ||
| typedef const typename A::value_type* const_reference; |
There was a problem hiding this comment.
reference and const_reference are removed in CXX23, value_type is equivalent
| class value_compare | ||
| : public std::binary_function<value_type, value_type, bool> | ||
| , private key_compare | ||
| : private key_compare |
There was a problem hiding this comment.
binary_function is not needed in newer CXX versions, its functionality is now done automatically and therefore it was removed
There was a problem hiding this comment.
ENDDO is the more modern approach, the old one also works but throws warnings
| #ifdef ENABLE_FAST_WAVES | ||
| #include <immintrin.h> | ||
| #include <memory.h> | ||
| #include <memory> |
There was a problem hiding this comment.
<memory> is more general, we had vocally reported issues in the past and <memory> seemed to fix them
| } | ||
| else{ | ||
| - B1*exp(-z*z/Hc/Hc)*R/r1*(3*r/r1- 2*r*r/r1*r1); | ||
| Bphi = - B1*exp(-z*z/Hc/Hc)*R/r1*(3*r/r1- 2*r*r/r1*r1); |
| } | ||
|
|
||
| void PeriodicMagneticField::setExtends(const Vector3d &origin) { | ||
| void PeriodicMagneticField::setExtends(const Vector3d &extends) { |
|
|
||
| if (fields.test(SerialNumberColumn)) | ||
| p += std::sprintf(buffer + p, "%10lu\t", | ||
| p += std::snprintf(buffer + p, buffersize - p, "%10" PRIu64 "\t", |
There was a problem hiding this comment.
"%10" PRIu64 "\t" is the same as "%10lu\t" in case of gcc and the same as "%10llu\t" in case of clang (that was a problem before)
| int64_t b = randInt(); | ||
| return (b + a << 32); | ||
| // a is shifted to the left to create a proper 64 bit integer | ||
| return (b + (a << 32)); |
There was a problem hiding this comment.
same as the old one, but does not throw a warning
| *p = twist(p[M - N], p[0], p[1]); | ||
| *p = twist(p[M - N], p[0], state[0]); | ||
| *p = twist(p[+M - N], p[0], p[1]); | ||
| *p = twist(p[+M - N], p[0], state[0]); |
There was a problem hiding this comment.
enum-enum-conversion was removed, the + fixes that
| std::string s; | ||
| v.push_back(s); | ||
| } | ||
| return Variant(v); |
There was a problem hiding this comment.
was missing for some reason
| #define INT_FUNCTION(to_type, fun, to) \ | ||
| to Variant::fun() const { \ | ||
| switch (type) { \ | ||
| switch (to_type) { \ |
CMakeLists.txt
Outdated
|
|
||
| set(CMAKE_CXX_STANDARD 11) | ||
| set(CMAKE_CXX_STANDARD 23) | ||
| set(CMAKE_CXX_STANDARD_REQUIRED True) |
There was a problem hiding this comment.
Throws an error during configure step if the cmake standard is not met instead of some undefined behavior during build time, that should help the user to determine potentially outdated CXX standards
|
Hi @JanNiklasB Thanks for the PR.
|
|
Hey,
|
|
Hi @JanNiklasB I agree with @rafaelab that we should be careful with backward compatibility on older compute clusters. At a minimum we should include a warning in the next v3.3 release notes that we will increase the minimum required version in the future. In this way, people will have a relatively recent official release as a fall back option, when their cluster does not support cxx20/23. How far CRPropa v4 is in the future depends in the end on us as the developers and can/should probably discussed in the next in person meeting. For ninja, I guess that people will not have issues to install that if they manage to install numpy. However, I suggest to wait with that until after the v3.3 release. |
|
Ok, I still would like to at least get rid of the warnings and the few typo caused bugs, should I modify this PR or make a new one without the changes to |
|
Fair enough. Fixing the typos and small bugs sounds good to me. |
|
I reversed the CXX23 requirement and ninja from the worklows, and changed the title accordingly. |
|
I am not sure why the ubuntu64 / 64x test failed, it happened in *: |
Hey,
with this PR I want to introduce the new CXX standard 23 to CRPropa, it enables us to use more modern code in future additions which should make it easier to contribute.
Furthermore CXX23 introduces the new deducing this which enables us to use CRTP (Curious Reoccurring Template Patterns) instead of vtables while keeping the fundamental structures of CRPropa, this is important for an eventual GPU extension.
I also tried to tackle many warnings that arose in the past, in the process of that I discovered some major bugs which I also fixed here (see comments in code for more details):
typeinstead ofto_typeinVariant.cppVariant.cppENDDOstatements insophia_interface.fsprintfreplaced withsnprintfFindGooglePerfTools.cmakeRandom.cppconstScaleBendoverin preconstructorextendsnever set inPeriodicMagneticField::setExtendsBphiinCMZField.cppif r<=r1clangandgccwhen formattinguint64_t, now using macro"%10" PRIu64 "\t"which set it automaticallyninjato workflows