Jump to content
  • Advertisement
Sign in to follow this  
chrisparton1991

C++: Strange malloc error with std::string

This topic is 3171 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hey, for some reason I can't seem to perform the simplest of input operations into a string using Xcode whilst in debug mode (On OSX 10.6). For example:
#include <cstdlib>
#include <iostream>
#include <string>

using namespace std;

int main()
{
	string someWord;
	cin >> someWord;
	if (someWord == "exit")
	{
		cout << "exit has been entered." << endl;
	}
	return 0;
}




If I do a debug build of the above code, it returns the following error after input (regardless of what's being typed): Using Strings(2838) malloc: *** error for object 0x1000041e0: pointer being freed was not allocated *** set a breakpoint in malloc_error_break to debug Abort trap Does anyone know why this would happen? Cheers. [Edited by - jpetrie on November 11, 2009 9:55:44 PM]

Share this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by chrisparton1991


Using Strings(2838) malloc: *** error for object 0x1000041e0: pointer being freed was not allocated
*** set a breakpoint in malloc_error_break to debug
Abort trap


Does anyone know why this would happen? Cheers.


This is a bug in the 10.6 SDK.

Share this post


Link to post
Share on other sites
Weird... That's a pretty big bug then. Do you think it's safe to just do release builds or will It just mask the error? The code runs fine when run as a release build.

Thanks, I was wondering why something as simple as that wasn't working.

EDIT: I looked it up and found that removing the preprocessor macros _GLIBCXX_DEBUG=1 and _GLIBCXX_DEBUG_PEDANTIC=1 fixes the debug error.

[Edited by - chrisparton1991 on November 11, 2009 9:20:43 PM]

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!