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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T07:24:04+00:00 2026-06-12T07:24:04+00:00

Windows 7 64 SP1, Boost 1.42, MS VS 2010 Ultimate, C++ This stripped down

  • 0

Windows 7 64 SP1,
Boost 1.42,
MS VS 2010 Ultimate,
C++

This stripped down code compiles and runs fine within the “Visual Studio x64 Command Prompt (2010)” using these switches:

cl /EHsc /W4 /nologo

#include <string>

using namespace std;        // I know not to use.

int main() {

  string sentence = "abc";
  string word_found = "";
  string::const_iterator it = sentence.begin();

  while ( *it != ' ' && it != sentence.end() )  
    word_found += *it++;                        
}

However, after compiling within the VS IDE, when run, it crashes with the error:

Expression: string iterator not dereferencable

The problem is apparently with the *it in ( *it != ' ' && it != sentence.end() ). I just need to short-circuit the expression so the now-right-hand expression, the *it != ' ', doesn’t evaluate:

while ( it != sentence.end() && *it != ' '  )

Then it runs well.

But why does it run flawlessly after compiling the original code from the command prompt? There is no other unusual behavior in the much larger program this subset is derived from. What doesn’t the string::iterator cause the same problem?

FWIW, these are the default MS VS command line options: /ZI /nologo /W3 /WX- /Od /Oy- /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_UNICODE" /D "UNICODE" /Gm /EHsc /RTC1 /GS /fp:precise /Zc:wchar_t /Zc:forScope /Fp"Debug\test short.pch" /Fa"Debug\" /Fo"Debug\" /Fd"Debug\vc100.pdb" /Gd /analyze- /errorReport:queue

Why do the command-line compiler and the IDE compiler produce different executables? Is there a switch I can add to the command prompt compiler that would make the executable behave in the same manner as when compiling from the VS IDE

  • 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-12T07:24:06+00:00Added an answer on June 12, 2026 at 7:24 am

    Those runtime checks are only enabled by default in debug builds. You either need to

    • build with one of the debug runtimes by compiling with the /MDd or /MTd option, or

    • enable checked iterators by changing the _ITERATOR_DEBUG_LEVEL to 1 (/D_ITERATOR_DEBUG_LEVEL=1).

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

Sidebar

Related Questions

Visual Studio Enterprise 2010, sp1, on Windows 7 64bit. Boost 1.48.0. Here begins the
I'm using Visual Studio 2010 sp1. with c++ and boost 1.47 in Windows 7
Environment: Windows 7 SP1 Visual Studio 2010 Ultimate SP1 .NET 4.0 I have a
I have a Windows 7 machine with Visual Studio 2005 SP1 installed. Using this,
I'm using Windows Vista Ultimate and today I've installed the Visual Studio 2008 SP1,
I am using Visual Studio 2010 SP1 in Windows 7 64bit dev box. My
This is a new install of Visual Studio 2008 SP1 on Windows 2008 (original)
I recently received a new workstation with Windows 7 SP1 and Visual Studio 2010
hello i working following system. windows 7 ultimate sp1 x64. visual studio 9 c++
I'm currently trying to build subversion 1.7.3 with Visual Studio 2010 SP1 on Windows

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.