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

Change TR_ASSERT_FATAL to static_assert in TR_AliasSetInterface #4933

Closed
Leonardo2718 opened this issue Mar 13, 2020 · 4 comments · Fixed by #7355
Closed

Change TR_ASSERT_FATAL to static_assert in TR_AliasSetInterface #4933

Leonardo2718 opened this issue Mar 13, 2020 · 4 comments · Fixed by #7355

Comments

@Leonardo2718
Copy link
Contributor

There are some instances of TR_ASSERT_FATAL in TR_AliasSetInterface [1,2,3] that should really be static_asserts. _AliasSetInterface is a template parameter so its value is known at compile time. Therefore, _AliasSetInterface == UseDefAliasSet || _AliasSetInterface == UseOnlyAliasSet can also be checked at compile time.

Note: the AliasSetInterface enum only has UseDefAliasSet and UseOnlyAliasSet as variants, so _AliasSetInterface == UseDefAliasSet || _AliasSetInterface == UseOnlyAliasSet may seem like a tautology. Unfortunatly, C++ allows casting arbitraty integers values to enum types, so it's possible to have code like TR_AliastSetInterface<(AliasSetInterface)42>. As a result, checking that the value of _AliasSetInterface makes sense is still a good idea.

[1]

TR_ASSERT_FATAL(_AliasSetInterface == UseDefAliasSet || _AliasSetInterface == UseOnlyAliasSet, "failed: can only call setAliases_impl for UseOnly or useDef presently");

[2]
TR_ASSERT_FATAL(_AliasSetInterface == UseDefAliasSet || _AliasSetInterface == UseOnlyAliasSet, "failed: can only call removeAllAliases for UseOnly or useDef presently");

[3]
TR_ASSERT_FATAL(_AliasSetInterface == UseDefAliasSet || _AliasSetInterface == UseOnlyAliasSet, "failed: can only call setAlias_impl for UseOnly or useDef presently");

@PaulinaQuintero
Copy link

Hi! I'm starting off contributing to open source. Can I check this?

@fjeremic
Copy link
Contributor

@PaulinaQuintero sure, we're always happy to accept new contributions! Feel free to open up a PR if you wish to tackle this one.

@PaulinaQuintero
Copy link

PaulinaQuintero commented Jun 22, 2020

I made a pull request with the changes that are requested but when making the tets it marks 6 errors in the porttest when I run the ctest, do you know why and how can I solve this? I would appreciate your help with this
image

@Leonardo2718
Copy link
Contributor Author

@PaulinaQuintero

Those port library test failures are unrelated to your change (I suspect they will fail without your change too). It should be safe for you to re-open your PR. When the CI tests run, we can verify that those failures are not your problem.

ChungHsuanChen added a commit to ChungHsuanChen/omr that referenced this issue May 1, 2024
This patch elimates use of TR_ASSERT_FATAL to static assert in AliasSetInterface.hpp

Issue: eclipse#4933
ChungHsuanChen added a commit to ChungHsuanChen/omr that referenced this issue Jun 1, 2024
Replace some uses of TR_ASSERT_FATAL with static_assert in AliasSetInterface.hpp

Issue: eclipse#4933
ChungHsuanChen added a commit to ChungHsuanChen/omr that referenced this issue Jun 1, 2024
Replace some uses of TR_ASSERT_FATAL with static_assert in AliasSetInterface.hpp

Issue: eclipse#4933
rmnattas pushed a commit to rmnattas/omr that referenced this issue Jun 14, 2024
Replace some uses of TR_ASSERT_FATAL with static_assert in AliasSetInterface.hpp

Issue: eclipse#4933
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants