[llvm-bugs] [Bug 39809] New: Wrong type of ternary expression; (void const*)0 erroneously treated as the null pointer constant

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Nov 27 10:28:22 PST 2018


https://bugs.llvm.org/show_bug.cgi?id=39809

            Bug ID: 39809
           Summary: Wrong type of ternary expression; (void const*)0
                    erroneously treated as the null pointer constant
           Product: clang
           Version: unspecified
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Frontend
          Assignee: unassignedclangbugs at nondot.org
          Reporter: pskocik at gmail.com
                CC: llvm-bugs at lists.llvm.org, neeilans at live.com,
                    richard-llvm at metafoo.co.uk

This compiles on gcc:

        //null-ptr constant select other type
        _Generic( 0?(int const*)0: (void*)0, int const*: (void)0); 
        //not null-ptr constant, ptr to void with combined qualifs
        _Generic( 0?(int const*)0: (void*)1, void const*: (void)0); 
        //not null-ptr constant, ptr to void with combined qualifs
        _Generic( 0?(int volatile*)0:(void const*)1, void volatile const*:
(void)0); 

        //GCC and CLANG disagree
        //not null-ptr constant, ptr to void with combined qualifs
        _Generic( 0?(int volatile*)0:(void const*)0, void volatile const*:
(void)0);

but clang types the last ternary as `int volatile*` treating `(void const*)0`
as the null pointer constant whereas gcc doesn't treat it as such.

I believe gcc is right here. The C standard defines the null pointer constant
as either `0` or `(void*)0`. It's weird, but `(void const*)0` doesn't qualify
(or qualifies way too much if you know what I mean).

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20181127/4a212a34/attachment.html>


More information about the llvm-bugs mailing list