[cfe-dev] [LLVMdev] Reminder: 3.6 branch is coming

David Chisnall David.Chisnall at cl.cam.ac.uk
Mon Jan 12 01:26:02 PST 2015


On 12 Jan 2015, at 08:07, Dimitry Andric <dimitry at andric.com> wrote:
> 
> 
> On 15 Oct 2014, at 19:42, Richard Smith <richard at metafoo.co.uk> wrote:
>> On 15 Oct 2014 05:12, "Ed Schouten" <ed at 80386.nl> wrote:
> ...
>> The test case in the LLVM tree is invalid and should be discarded. It
>> erroneously assumes that the encoding of wchar_t is independent of the
>> locale.
>> 
> That makes no sense. These value are compile-time constants and cannot possibly depend on the locale.

I believe Richard is wrong here.  There are a number of similar compile-time constant macros in the C spec.  I believe the clue as to the correct reading of the spec is in the name of the macro: __STDC_MB_MIGHT_NEQ_WC__

Note the word *might*.  It means that it is not safe for code to assume that a cast will give the corresponding char value if one exists.  i.e. that assumption is not true for all locales.

As dim says, the test is wrong.  It would be a valid test for it to fail if __STDC_MB_MIGHT_NEQ_WC__ is *not* defined and not all characters in the basic set have the same encoding as wide chars, but it is not correct to fail if it is set unless that have the same encoding in *all* locales, *and* the vendor is willing to guarantee that they will have the same encoding for all locales in all future binary-compatible versions of the system (which an automated test can't check).

In summary: the test is nonsense and should be removed.

David





More information about the cfe-dev mailing list