• 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
fshort-wchar
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

fshort-wchar


  • Subject: fshort-wchar
  • From: Anders Markussen <email@hidden>
  • Date: Fri, 13 Apr 2012 14:36:23 +0200

There seems to be a problem in clang with integral promotions on wchar_t with -fshort-wchar.
Using Xcode 4.2.1 / clang 3.0

#include <stdlib.h>
#include <stdio.h>

int compare(void const* ap, void const* bp) {
        const wchar_t *a=(const wchar_t *)ap, *b=(const wchar_t *)bp;
        while (*a && *b && (*a == *b)) {
                ++a; ++b;
        }
        return *a-*b;
}

int main() {
        const wchar_t* fruit[] = { L"apricot",L"banana" };
        printf("%d %d\n", L'a'-L'b', compare(fruit[0], fruit[1]));
        qsort(fruit, 2, sizeof(wchar_t*), compare);
	// At this point, in clang, the array has been mis-sorted.
        return 0;
}


$ g++ -Wall -fshort-wchar -o wchar wchar.cpp
$ ./wchar
-1 -1

$ clang++ -Wall -fshort-wchar -o wchar wchar.cpp
wchar.cpp:14:11: warning: conversion specifies type 'int' but the argument has
type 'wchar_t' [-Wformat]
        printf("%d %d\n", L'a'-L'b', compare(fruit[0], fruit[1]));
                ~^        ~~~~~~~~~
1 warning generated.
$ ./wchar
65535 65535

Known? Intended? It hurts our transition from llvm-gcc 4.2 to clang.

- Anders Markussen


 _______________________________________________
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: fshort-wchar
      • From: Ron Hunsinger <email@hidden>
  • Prev by Date: Re: Cannot use Instruments
  • Next by Date: Re: Where does XCode 4.3.2 store account information?
  • Previous by thread: Re: Cannot use Instruments
  • Next by thread: Re: fshort-wchar
  • Index(es):
    • Date
    • Thread