Let's consider I have a class Permission which is constructed with a username and a permission identifier. The constructor of this permission class will check if the user has that specific permission and throws if not.
Inside the api request handler, these permission objects are stack variables and constructed with a user and a permission. I expect a throw if there is no permission for that user.
Is there a guarantee that these permission objects won't be optimized out because I just construct them but never use them again (They need to throw if the permission is denied)?