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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T21:56:45+00:00 2026-06-08T21:56:45+00:00

Our team just ran into the same issue described here http://forums.codeguru.com/archive/index.php/t-514404.html , i.e. calling

  • 0

Our team just ran into the same issue described here http://forums.codeguru.com/archive/index.php/t-514404.html, i.e. calling some_vec.resize(new_size), where N = new_size - some_vec.size() with N >= 2, and VC10 default-constructed all N new elements, whereas GCC default constructed a single element, as the prototype element, to copy-construct it N times for the new elements.

Since this is a vector of uuid, where the default-constructor randomly initializes each new instance, we ended up with N times the same uuid with GCC and N different uuids with VC. That was enough to wreak havoc in our test suite on one platform but not another, and was no fun to find.

My question is thus: who is right? VC or GCC? Or is this one of those beloved corners of C++ that’s unspecified? TIA, –DD

  • 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-08T21:56:48+00:00Added an answer on June 8, 2026 at 9:56 pm

    I bet if you compile GCC with -std=c++0x, you’ll get the same result as with MSVC, that is, the N default constructions. This has changed in C++11, see here. There are now two overloads, one with just the new size that default constructs the new elements, and another that takes a “prototype” parameter to copy-construct every new element from.

    Now, to get consistent results no matter what mode you compile in, just use

    v.resize(new_size, T());
    

    Background info: The change was necessary, since there are now types that can be movable, but not copyable (like std::unique_ptr). The old signature demanded copyability. Now the first template parameter to standard container types is only required to be copyable, if you use operations that require a copy.

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

Sidebar

Related Questions

Our team has just started unittesting and mocking, and we have run into some
Our team is just ramping up to use source control through SVN. We are
Our team has just started developing for the Sitecore CMS. We find that after
So my team is just starting to use branches on our project, and we've
We are just about to implement full blown TFS 2008 across our development team
My team (4 people) have just reached a major milestone in our development, putting
Our Team Foundation Server has to build three different versions of the same solution.
Our team is just getting started with Mercurial. One of the first things we've
Our team has just moved from Netbeans to IntelliJ 9 Ultimate and need to
I am working on a simple accordion-like vertical menu: http://www.cybart.com/bscg/ Clicking on OUR SOLUTIONS,

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.