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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T19:28:21+00:00 2026-05-15T19:28:21+00:00

When using the std::map with types that use trivial, non-throwing, copy constructors, a compiler

  • 0

When using the std::map with types that use trivial, non-throwing, copy constructors, a compiler warning/error is thrown (warning level 4, release mode) for unreachable code in xtree. This is because the std::map has a try-catch in it that helps maintain the state of the tree in the case of an exception, but the compiler figures out that the catch statement will never be called if the stored elements don’t throw. These warnings can be easily suppressed with the following lines at the top of the .cpp file:

#pragma warning(push)
#pragma warning(disable:4702)
#include <xtree>
#pragma warning(pop)

Is there a way to bypass this warning/error without changing the warning level, building in debug, suppressing the warning, or using a different type in the map? Is there plans to change this in the standard library?

Update:
Maybe it is compiler specific. I am using vc7.
The error is below:

c:\program files\microsoft visual studio .net 2003\vc7\include\xtree(1116) : error C2220: warning treated as error – no ‘object’ file generated
c:\program files\microsoft visual studio .net 2003\vc7\include\xtree(1116) : warning C4702: unreachable code

Apparently the xtree is used by the std::map.

  • 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-05-15T19:28:22+00:00Added an answer on May 15, 2026 at 7:28 pm

    Unfortunately it looks like xtree is part of the underlying implementation of map in VC7, and as such there isn’t much that can be done to mitigate it. It looks like it’s a bug in the standard library.

    Is it a possibility to use a newer compiler? I’m fairly sure there are free downloads of more recent versions of the compiler you could use, and perhaps they’ve fixed this issue.

    If that’s not an option, probably the best solution is to wrap the include of map into your own private header, complete with a comment and the #pragma+include <xtree> lines you already discovered (in addition to an include of map. This way you hide the workaround from normal use.

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

Sidebar

Related Questions

I have a std::map that I'm using to store values for x and y
I'm attempting to use std::find_if on a std::map, looking for a particular object that
I'm using std::map to store a lot of elements (pairs of elements) and I
using c++ std's unordered_map i want to map an integer triplet to a single
i have a std::map and i am using iterator to find a certain key,value
I am having problems using my custom class with a std::map. The class dynamically
using namespace std; class A { public: A() {} ~A() {} map<int, string*>& getMap()
I have a class with a static std::map member variable that maps char s
So, I'm using a std::map as an associative array. The map is declared as
I'm trying for several days to simulate a non-deterministic finite automata, using a map

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.