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

Make return-type a compilation error #8362

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ilya071294
Copy link
Contributor

This protects from undefined behavior cases that can be added to the code by mistake.

This protects from undefined behavior cases that can be added to the code by mistake.
@@ -1124,6 +1124,7 @@ namespace
return twelveHours == 12 ? twelveHours : 12 + twelveHours;

cb->err(Arg::Gds(isc_incorrect_hours_period) << string(period.data(), period.length()));
Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder if this line can do anything but throw. If no it would be better to mark it as noreturn and undo addition of return.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Normally it should throw. But we still can't be 100% sure. If we add noreturn and cb->err won't throw, the server will crash. I prefer to avoid such cases as well.

Copy link
Member

@AlexPeshkoff AlexPeshkoff Dec 25, 2024

Choose a reason for hiding this comment

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

I tend to agree with @aafemt - err function always throws, that's unconditional behavior.

But there is another side of a question. My old hack with passing different error raising calls was (among others) added to support descriptors in qli, at the same time avoid calls (like MOB_/CVT_) from qli directly to jrd and keep correct diags in engine. Currently, when qli is gone away, ideally that hack should better be rolled back. After that we will get here [[ noreturn ]] function in usual way.

I.e. please mark err function as [[ noreturn ]], it will be cleaned out together with both cb and err in it. IMO further deep modifications of this code make no sense.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I.e. please mark err function as [[ noreturn ]], it will be cleaned out together with both cb and err in it. IMO further deep modifications of this code make no sense.

BTW, I have no idea how to mark err as noreturn while it's a function pointer.

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.

3 participants