This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Add new built-in: __builtin_unreachable()

Richard Guenther wrote:
On Mon, Jun 8, 2009 at 2:34 PM, David Daney<> wrote:
Ian Lance Taylor wrote:
David Daney <> writes:

+@deftypefn {Built-in Function} void __builtin_unreachable (void)
+This function is used to indicate to the compiler that control flow
+will never reach the point of the @code{__builtin_unreachable}.  If
+control flow does reach @code{__builtin_unreachable}, program behavior
+is undefined.  The only valid use of this builtin is immediately
+following an @code{asm} statement that either never exits or transfers
+control elsewhere never returning.
I have wanted __builtin_unreachable for a while, but never got around to
doing anything.  But I only want it if it works in general, not just
after an asm statement.  I think it should mean "if control flow reaches
this point, the program is undefined."  Ideally there should be a
command line option to control it, so that it is possible to compile
__builtin_unreachable as expanding to abort, or something like that,
when debugging.

Ok, then how about this version?  All my original commentary still applies:

I have added a new command line flag (-funreachable-traps) that causes
__builtin_unreachable() to be expanded exactly as if it were a

I wouldn't add a new flag to do this. In fact preprocessor wrapping around the two builtins can do this. Or was there a particular reason?

My reason was that I thought iant requested it. Although '-D__builtin_unreachable=__builtin_trap' might accomplish the same thing without polluting the flag namespace.

David Daney

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]