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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T23:14:41+00:00 2026-06-03T23:14:41+00:00

Given code like the following: void f() { int i; i = 0; }

  • 0

Given code like the following:

void f()
{
   int i;
   i = 0;
}

is it possible the system could throw an exception due to the simple assignment?

[Edit: For Those saying, “No an exception cannot occur,” can You point Me in the direction of the part of the C++ standard which says this? I am having trouble finding it.]

  • 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-03T23:14:42+00:00Added an answer on June 3, 2026 at 11:14 pm

    Although you’d probably be hard put to find an assurance of it in the standard, a simple rule of thumb is that anything that’s legitimate in C probably can’t throw. [Edit: The closest I’m aware of to a direct statement to this effect is at §15/2, which says that:

    Code that executes a throw-expression is said to “throw an exception;” […]

    Looking at that in reverse, code that does not execute a throw-expression does not throw an exception.]

    Throwing is basically restricted to two possibilities: the first is invoking UB. The second is doing something unique to C++, such as assigning to a user-defined type which overloads operator =, or using a new expression.

    Edit: As far as an assignment goes, there are quite a few ways it can throw. Obviously, throwing in the assignment operator itself would do it, but there are a fair number of others. Just for example, if the source type doesn’t match the target type, you might get a conversion via a cast operator in the source or a constructor in the target — either of which might throw.

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

Sidebar

Related Questions

Given the following code: using System; namespace Sandbox { class CommandLine { static void
I have the following code: typedef void VOID; int f(void); int g(VOID); which compiles
I tried the following code #include <stdio.h> int main(void) { typedef static int sint;
I have been given some generated code which looks like so: <form id=form1 method=post
The following piece of code was given to us from our instructor so we
Given the following code and the suggestions given in this question , I've decided
Given the following pieces of code, which one is more efficient? The real method
Consider the following code: public abstract class Base { public void getAnswer(); } public
If I have a function void Foo(params int[] bar){} The following runs fine: int[]
I have following code: typedef enum { FOO, BAR, BAZ } foo_t; static void

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.