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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T04:56:38+00:00 2026-06-14T04:56:38+00:00

This seems simple to me but I’m having trouble actually finding anything explicitly stating

  • 0

This seems simple to me but I’m having trouble actually finding anything explicitly stating this.

Does std::string stringArray[3] not create an array of std::string objects, the way that SomeType typeArray[3] would? The actual number is irrelevant; I just picked 3 arbitrarily.

In the Visual Studio 2010 debugger, it appears to create a single string as opposed to an array of strings. Why?

Wild guess: is it calling the default std::string constructor, and then invoking an unused access of index 3? If so, why doesn’t that cause an out of bounds exception on an empty string?

Does this have something to do with overloading the [] operator?

There are plenty of ways to code the same things without specifically using an array of std::string without issue, but what is the explanation/justification for this behavior? It seems counterintuitive to me.

Edit: I found this thread std::string Array Element Access in which the comments on the answer appear to observe the same behavior.

  • 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-14T04:56:40+00:00Added an answer on June 14, 2026 at 4:56 am

    The OP is NOT losing his mind. But Visual Studio’s integrated debugger certainly is. I believe this is a bust in the detection of operator [] for std::string, which is sad However, it does work correctly for std::vector<std::string>

    An excellent reference to how you can get around this using the watch-window (no way to do it using the Auto or Locals window afaik) can be found at this previously posted question. This is also an extremely helpful method for viewing pointer-based dynamic arrays (arrays allocated with Type *p = new Type[n];). Hint: use “varname,n” where varname is the variable (pointer or fixed array), and ‘n‘ is the number of elements to expand.

    A demonstration is in order to show a declared C-array of std::string and what the OP was observing, and a std::vector<std::string> to show what things should look like:

    int main(int argc, char *argv[])
    {
        std::string stringArray[3];
        std::vector<std::string> vecStrings(3);
        return 0; // set bp *here*
    }
    

    enter image description here

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

Sidebar

Related Questions

This seems simple enough, but I'm having difficulty finding an answer. I have a
this question seems simple but I can't find anything on the web. In my
This seems like it should be simple but I can't find anything yet. In
This seems like a simple thing but google hasn't turned up anything for me:
This seems like a simple question but I cannot find anything on adding a
This seems simple but I've exhausted my Google search patience. I have a RelativeLayout
This seems simple but I can't figure it out. I receive post data in
This seems like it should be very simple but I can't get it to
All, this seems like a simple problem but it's giving me fits. Lets say
This seems like such a simple issue but I cannot find an elegant solution.

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.