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

  • Home
  • SEARCH
  • 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 7929361
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T20:02:58+00:00 2026-06-03T20:02:58+00:00

In gcc 4.2, this works: #include <stdexcept> #include <iostream> int main() { try {

  • 0

In gcc 4.2, this works:

#include <stdexcept>
#include <iostream>

int main() {
    try {
        throw std::runtime_error("abc");
    } catch (const std::exception& ex) {
        std::cout << ex.what();
    }
}

In Xcode 4.3.2 (iOS with LLVM 3.1, -std=c++11), this fails with terminate called throwing an exception, never reaching the NSLog(…) line:

#include <stdexcept>

int main() {
    try {
        throw std::runtime_error("abc");
    } catch (const std::exception& ex) {
        NSLog(@"%s", ex.what());
    }

    return UIApplicationMain(argc, argv, nil, nil);
}

But this works:

#include <stdexcept>

int main() {
    try {
        throw std::runtime_error("abc");
    } catch (const std::runtime_error& ex) {
        NSLog(@"%s", ex.what());
    }

    return UIApplicationMain(argc, argv, nil, nil);
}

What gives?

  • 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-03T20:02:59+00:00Added an answer on June 3, 2026 at 8:02 pm

    gcc is correct:

    15.3p3 A handler is a match for an exception object of type E if

    • … or
    • the handler is of type cv T or cv T& and T is an unambiguous public base class of E, or
    • …

    This sounds like an xcode bug (and a surprisingly basic one!)

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

Sidebar

Related Questions

#include<iostream> #include<vector> std::vector<std::string> vector1; int main() { vector1.push_back(adadad); std::vector<std::string> vector2; vector2.push_back(adadd); if (vector1==vector2) {
I compiled this (gcc compiler) : #include< stdio.h> main() { unsigned char ch; FILE
I compiled this (gcc compiler): #include <stdio.h> main() { struct { a:1; b:2; }
see this code #include<stdio.h> int main() { void test(void) { printf(test); return; } printf(main);
This code gives me warnings: $ cat test.c #include<stdio.h> #include<time.h> int main() { time_t
The following code gives a compiler error (gcc-4.7 run with -std=c++11 ): #include <iostream>
I wrote this code that compiles on Solaris gcc it works fine too for
Recently I tried compiling program something like this with GCC: int f(int i){ if(i<0){
This code compiles fine with GCC and Clang but not with MSVC 2010: #include
Here's a small test program I wrote: #include <iostream> using namespace std; class 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.