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

tests/misc: check sealed vs. local/global #363

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

nwf
Copy link
Member

@nwf nwf commented Dec 2, 2024

No description provided.

@nwf nwf requested review from davidchisnall and rmn30 December 2, 2024 19:25
tests/misc-test.cc Outdated Show resolved Hide resolved
@nwf nwf force-pushed the 202412-test_seal_scoping branch 2 times, most recently from 7eea080 to bd10ac1 Compare December 9, 2024 16:05
tests/misc-test.cc Outdated Show resolved Hide resolved
@nwf nwf force-pushed the 202412-test_seal_scoping branch from bd10ac1 to d62b3dc Compare December 9, 2024 19:55
sdk/include/cheri.hh Outdated Show resolved Hide resolved
TEST_EQUAL(oLocal1.type(),
o.type(),
"Loading global sealed cap through non-LoadGlobal bad type");
TEST_EQUAL(static_cast<PermissionSet>(oLocal1.permissions()),
Copy link
Collaborator

@rmn30 rmn30 Dec 9, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had to add this cast in the same situation recently and it is slightly annoying. Could we have an implicit conversion or is that a bad idea? You can also get rid of if you make oLocal1 const as there is a const version of the permissions method that returns a PermissionSet.

Copy link
Member Author

@nwf nwf Dec 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The conversion is already there:

/**
* Implicitly convert to a permission set.
*/
operator PermissionSet() const
{
return permission_set_from_pointer(ptr());
}
However, I believe what's going on is as https://en.cppreference.com/w/cpp/language/template_argument_deduction#Implicit_conversions sayeth:

Type deduction does not consider implicit conversions (other than type adjustments listed above): that's the job for overload resolution, which happens later.

So after type deduction, there's nothing that could define DebugFormatArgumentAdaptor<CHERI::Capability<void>::PermissionsProxy>, and so overload resolution has an empty set of options to consider. AIUI, the static_cast explicitly invokes the implicit conversion, and the const option changes the overload resolution behavior of .permissions(), since the const-qualified option is more specific. Blech.

@nwf nwf force-pushed the 202412-test_seal_scoping branch from d62b3dc to 034abd7 Compare December 10, 2024 17:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants