-
Notifications
You must be signed in to change notification settings - Fork 276
ID_* symbols are now constexpr #2133
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
Conversation
My understanding of a past discussion of introducing |
Yes, you could, if you also enable the #if 0 in line 41 in src/util/dstring.h. The key disadvantage is that this allows also all other conversions to int, e.g., in an if, or a plain assignment. The other problem is that this will never work with std::string, i.e., once we start using switch, then USE_DSTRING must be on from thereon. It is not clear to me what the benefit of enabling the compiler to have more compile-time constants is in general. This may also change over time. |
#include "irep_ids.def" // NOLINT(build/include) | ||
}; | ||
|
||
#ifdef __GNUC__ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Clang, MSVC 2015+ also have this. Suggest stealing the testing logic used at https://github.com/diffblue/cbmc/blob/develop/src/nonstd/optional.hpp#L87
I've just added another commit that allows conversion to the enum class. This prevents accidental conversion to int, pointers, bool etc., but enables switch(some_id) { case ID_...:; }. This is a serious benefit in my view. The price is that we have to ditch versions of Visual C++ prior to 2015. Also, we cannot use std::string any longer as alternative to the hashed strings. Views? |
Do you have any feel on how many Windows users are out there, and if so what their limitations are? We currently require MSVC2013, which is an odd version, having sort-of-but-broken C++11 support, so it would be a surprising place for people to be stuck |
There are some left, but are getting fewer and fewer. I'll send emails. |
My current view is to merge this, but not yet use switch(...) in cbmc itself for a release or two. Dependent software that is gcc/clang-only can then start using this now. |
So what is the "enhancement" for now? Smaller binaries, faster code, something else? For sure theory tells us that the switch/case should be faster than a chain of if/else, but is this also true in practice? With |
790bf49
to
b21d45b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR failed Diffblue compatibility checks (cbmc commit: b21d45b).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/85621224
Status will be re-evaluated on next push.
Please contact @peterschrammel, @thk123, or @allredj for support.
Common spurious failures:
- the cbmc commit has disappeared in the mean time (e.g. in a force-push)
- the author is not in the list of contributors (e.g. first-time contributors).
b21d45b
to
8765b34
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR failed Diffblue compatibility checks (cbmc commit: 8765b34).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/86396183
Status will be re-evaluated on next push.
Please contact @peterschrammel, @thk123, or @allredj for support.
Common spurious failures:
- the cbmc commit has disappeared in the mean time (e.g. in a force-push)
- the author is not in the list of contributors (e.g. first-time contributors).
3376932
to
651af68
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR failed Diffblue compatibility checks (cbmc commit: 651af68).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/87621638
Status will be re-evaluated on next push.
Please contact @peterschrammel, @thk123, or @allredj for support.
Common spurious failures:
- the cbmc commit has disappeared in the mean time (e.g. in a force-push)
- the author is not in the list of contributors (e.g. first-time contributors).
The incompatibility may have been introduced by an earlier PR. In that case merging this
PR should be avoided unless it fixes the current incompatibility.
4816beb
to
00eb39b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✔️
Passed Diffblue compatibility checks (cbmc commit: 00eb39b).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/94117295
00eb39b
to
a9af8bb
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✔️
Passed Diffblue compatibility checks (cbmc commit: a9af8bb).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/97924137
a9af8bb
to
d358fee
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✔️
Passed Diffblue compatibility checks (cbmc commit: d358fee).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/98233189
d358fee
to
3ce1575
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✔️
Passed Diffblue compatibility checks (cbmc commit: 3ce1575).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/99567549
3ce1575
to
c3ba809
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✔️
Passed Diffblue compatibility checks (cbmc commit: c3ba809).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/100693494
c3ba809
to
597330e
Compare
65e7981
to
57751ae
Compare
Closing due to age (no further comment on PR content), please reopen with rebase on develop if you intent to continue this work. |
This partially reverts 38782bd.
The idea is that the ID_* symbols can be constexpr, which may help a sophisticated compiler. The question whether it does should be investigated. A disadvantage is that the symbols need to be parsed twice, which may affect compile time.