Bug 27365 - add a way to mark that a path cannot be taken, something like __builtin_unreachable()
Summary: add a way to mark that a path cannot be taken, something like __builtin_unrea...
Status: RESOLVED INVALID
Alias: None
Product: gcc
Classification: Unclassified
Component: tree-optimization (show other bugs)
Version: unknown
: P3 enhancement
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-04-30 19:23 UTC by Dan Nicolaescu
Modified: 2006-04-30 19:34 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Dan Nicolaescu 2006-04-30 19:23:57 UTC
It would be nice to have some form of a builtin that shows that a portion of the code is not reachable, and it generates no code in the binary. 

gcc_unreachable() is used now in the gcc sources for this, but it will generate assembly code that calls abort().

Another way to accomplish the same thing could be with attributes
Can attributes be used for function calls? I beleive right now they can't. 
If they could, then something like this could work:
myfunc(foo,bar,baz) __attribute__((noreturn));
Some functions are known not to return only in certain situations, so they cannot be declared as being "noreturn". An example where this would be useful is the Fsignal function in emacs.
Comment 1 Andrew Pinski 2006-04-30 19:34:52 UTC
Actually gcc_unreachable is to make sure that the compiler is constaint.

Really marking a path as unreachable is the same thing as using __builtin_expect.