• 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
Possible Clang Bug in Initializing Wide String From String Literal?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Possible Clang Bug in Initializing Wide String From String Literal?


  • Subject: Possible Clang Bug in Initializing Wide String From String Literal?
  • From: Andreas Grosam <email@hidden>
  • Date: Thu, 19 May 2011 17:56:26 +0200

The code below ...

//  main.c
//  UTF8-encoded source file

#include <stdio.h>
#include <wchar.h>

int main (int argc, const char * argv[])
{
    char s[] = "ü";
    wchar_t ws[] = L"ü";
    printf("number of characters in narrow string:  %lu\n", sizeof(s)/sizeof(char) - 1 );
    printf("number of characters in wide string:    %lu\n", sizeof(ws)/sizeof(wchar_t) - 1 );
    printf("\n");
    return 0;
}



... yields the following with gcc 4.2:

number of characters in narrow string:  2
number of characters in wide string:    1


and with clang (Xcode 4.0.2):

number of characters in narrow string:  2
number of characters in wide string:    2



IMHO, if I read the standard correctly, clang seems to make an error here. I hope I'm terrible wrong here, since this is pretty basic stuff. Is there something left to be "implementation defined" what I may have overlooked?


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: Possible Clang Bug in Initializing Wide String From String Literal?
      • From: Sean McBride <email@hidden>
    • Re: Possible Clang Bug in Initializing Wide String From String Literal?
      • From: Mark Wagner <email@hidden>
  • Prev by Date: Adding an "item reference" not a "file reference" to a Link Build Phase
  • Next by Date: Bug with NSPredicateEditor in Xcode 4
  • Previous by thread: Adding an "item reference" not a "file reference" to a Link Build Phase
  • Next by thread: Re: Possible Clang Bug in Initializing Wide String From String Literal?
  • Index(es):
    • Date
    • Thread