• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Rép : XCode, cin and string (C++) => troubles :s
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Rép : XCode, cin and string (C++) => troubles :s


  • Subject: Rép : XCode, cin and string (C++) => troubles :s
  • From: Arnaud Schoofs <email@hidden>
  • Date: Sun, 14 Feb 2010 15:27:08 +0100

Thanks again for your help !

Like you i'm more and more convinced that it's some kind of bug in XCode.

As you said, i can get rid of the bug using :
string s = "a";

Except if someone find the exact source (and solution) of the "bug" i'll stop investigate it and use this solution.

By the way, i want to mention a last interesting point :
Considering this source :
using namespace std;
int main (int argc, char * const argv[]) {
string input;
cout << "type something :";
getline(cin, input);
cout << "you entered : " << input << endl << endl;
    return 0;
}
I've used 3 ways to compile it :
1) In a terminal with a standard makefile
2) With XCode in Release mode
3) With XCode in Debug mode

I've ran the 3 executable in a standard terminal, but the results are different :
1) No errors, working fine
2) Surprisingly : No errors, working fine !!!!
3) Same error as i mentioned before

I've search for the differences between the config Debug/Release in XCode, but i didn't find anything interesting.

I think i'm gonna report this bug to apple but i haven't got much hope that i'll be solved soon ^^

Best regards.

Le 14 févr. 2010 à 15:08, Andreas Grosam a écrit :

Yes, it is a bug in the std C++ library.


The last time I heard of an issue which could cause this bug is already some years ago. But Apple uses a quite old implementation of the C++ library. So, its likely, this bug is still there.

I'm only guessing, because I'm too lazy to look into the actual sources, but at the time this bug was apparent, it was caused by an "optimization" for empty strings. That is, the empty string "" was shared globally. Of course, you cannot delete the buffer to a static buffer, like:

namespace {
 const char* empty_string = "";
}
..
delete empty_string;

This would cause the exact same message you get.


To be completely  honest, it seems, Apple is treating C++ and also the standard C++ library like a poor cousin. Due to its age (its actually GNU C++ lib, but quite old) there are still bugs. And due to its dependency to Apples C lib and missing maintenance, there is a complete lack of support for locale. There is only the "C" locale, that is: no encoding, no reasonable usage for wchar_t, no UTF-8, no date, money, collating, formatting, and so on. Well, except, you abuse another bug, namely that the C++  lib always uses the current global POSIX locale.


Ah, forgot:
A workaround would possibly be to use:

std::string s = "a";  

where the string s is not default constructed and doesn't use an empty string.



Regards
Andreas

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Rép : XCode, cin and string (C++) => troubles :s
      • From: Andreas Grosam <email@hidden>
  • Prev by Date: Re: XCode, cin and string (C++) => troubles :s
  • Next by Date: Re: Rép : XCode, cin and string (C++) => troubles :s
  • Previous by thread: coredata in instruments (iPhone)
  • Next by thread: Re: Rép : XCode, cin and string (C++) => troubles :s
  • Index(es):
    • Date
    • Thread