Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9248217
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T09:54:03+00:00 2026-06-18T09:54:03+00:00

I have a function defined as: int f_2() { rand(); return 10; } clang

  • 0

I have a function defined as:

int f_2() {
  rand();
  return 10;
}

clang breaks it up into 3 basic blocks. This is understandable.

however when I replace the call to rand() by exit(0), then it breaks it into 4 basic blocks.
Wikipedia (http://en.wikipedia.org/wiki/Basic_block) says that functions that cannot return can be at the end of a basic block.

How does clang know that exit() function does not return?
I am compiling my code with clang -c.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T09:54:03+00:00Added an answer on June 18, 2026 at 9:54 am

    clang is a C compiler. It’s permitted to take advantage of guarantees made by the language standard for standard library functions.

    There may also be something in the particular implementation of <stdlib.h> that marks exit() as a function that doesn’t return, perhaps using a language extension or the _Noreturn keyword added by the 2011 ISO C standard.

    Another example of this: the call sin(0.0), with -O1 or higher, compiles to a literal 0.0, because the compiler knows about the sin function. (Which means that a program that calls sin(0.0) needs to be linked with -lm only if you don’t optimize it.)

    This is all permitted because a program that defines its own (non-static) function with the same name as a standard library function has undefined behavior; the compiler needn’t consider the possibility that a call to exit or sin does anything other than what the standard specifies for those functions.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an inline member function defined under class MyClass int MyClass::myInlineFunction(); This function
I have this user defined function. public partial class UserDefinedFunctions { static int i;
I have Javascript function defined in the main index.html file. One part of this
I have a function defined like this: public static void ShowAbout(Point location, bool stripSystemAssemblies
Suppose I have a function defined like this: class Foo() { public: void bar(MyClass*
In an ASP.MVC application, I have a function defined in my _ViewStart.cshtml like this:
I have defined my own compare function for a priority queue, however the compare
I'm working with Code::Blocks with MinGW on Windows 7; I have this function that
Suppose I have a macro defined as this: #define FOO(x,y) \ do { int
I have a function pointer defined by: typedef void (*EventFunction)(int nEvent); Is there a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.