Skip to content

Add __attribute__((noreturn,cold)) for _mi_assert_fail #134586

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

Closed
picnixz opened this issue May 23, 2025 · 1 comment
Closed

Add __attribute__((noreturn,cold)) for _mi_assert_fail #134586

picnixz opened this issue May 23, 2025 · 1 comment
Labels
interpreter-core (Objects, Python, Grammar, and Parser dirs) type-feature A feature request or enhancement

Comments

@picnixz
Copy link
Member

picnixz commented May 23, 2025

Feature or enhancement

Note

I already have a PR ready in case this is accepted

Proposal:

Because _mi_assert_fail is not marked as a noreturn function, the assertion is not understood by CLion and I have some false positives telling me "this ptr is not NULL" while just above there is mi_assert(ptr != NULL);. To improve IDE's analysis, I suggest to mark _mi_assert_fail with __attribute__((noreturn)) and __THROW for GCC, the same attributes that are put on __assert_fail:

extern void __assert_fail (const char *__assertion, const char *__file,
			   unsigned int __line, const char *__function)
     __THROW __attribute__ ((__noreturn__));

cc @colesbury

Has this already been discussed elsewhere?

This is a minor feature, which does not need previous discussion elsewhere.

Linked PRs

@picnixz picnixz added type-feature A feature request or enhancement interpreter-core (Objects, Python, Grammar, and Parser dirs) labels May 23, 2025
@thesamesam
Copy link
Contributor

You could mark it cold as well while at it. The equivalent in glibc has that with latest versions (f6f904745942540c7ea99c403b75b695ee560035, e3b0b3484cac61f9eae373751ac6eaf816a2c9c3).

@picnixz picnixz changed the title Add __attribute__((noreturn)) for _mi_assert_fail Add __attribute__((noreturn,cold)) for _mi_assert_fail May 24, 2025
picnixz added a commit that referenced this issue May 30, 2025
…134624)

We add the following attributes on `_mi_assert_fail` to help IDE introspection:

* `__attribute__((__noreturn__))`
* `__attribute__((cold))`
* `__THROW` (GCC only)
@picnixz picnixz closed this as completed May 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
interpreter-core (Objects, Python, Grammar, and Parser dirs) type-feature A feature request or enhancement
Projects
None yet
Development

No branches or pull requests

2 participants