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 7908873
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T12:07:59+00:00 2026-06-03T12:07:59+00:00

[dcl.attr.noreturn] provides the following example: [[ noreturn ]] void f() { throw error; //

  • 0

[dcl.attr.noreturn] provides the following example:

[[ noreturn ]] void f() {
    throw "error";
    // OK
}

but I do not understand what is the point of [[noreturn]], because the return type of the function is already void.

So, what is the point of the noreturn attribute? How is it supposed to be used?

  • 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-03T12:08:00+00:00Added an answer on June 3, 2026 at 12:08 pm

    The [[noreturn]] attribute is supposed to be used for functions that don’t return to the caller. That doesn’t mean void functions (which do return to the caller – they just don’t return a value), but functions where the control flow will not return to the calling function after the function finishes (e.g. functions that exit the application, loop forever or throw exceptions as in your example).

    This can be used by compilers to make some optimizations and generate better warnings. For example if f has the [[noreturn]] attribute, the compiler could warn you about g() being dead code when you write f(); g();. Similarly the compiler will know not to warn you about missing return statements after calls to f().

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

Sidebar

Related Questions

In the Standard-Text there is an example in 8.5.4 (3) List-initialization [dcl.init.list] struct S
I have a DCL script on VMS which calls a perl script. Is there
After answering this question and not finding a satisfying answer in the standard paper,
here my function with setTimout call just immedieatly after the click but i wants
I've noticed that I can not use all unicode characters in my python source
I know that all forums are full of such question, but I've tried few
I have an mnesia database dump from an ejabberd server (DCD, DCL, and DAT
I took the code of DCL from Joe Duffy's book 'Concurrent programming on windows'
If you have an interesting story to share, please post an answer , but
I'm writing a program that executes different sql statements(query, dml, ddl, dcl). How can

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.