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

            Bug ID: 44855
           Summary: Combining a pointer to array of const TYPE with an
                    otherwise size-compatible array of TYPE should work
                    and yield only a _pedantic_ warning
           Product: clang
           Version: 9.0
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: C
          Assignee: unassignedclangb...@nondot.org
          Reporter: psko...@gmail.com
                CC: blitzrak...@gmail.com, dgre...@apple.com,
                    erik.pilking...@gmail.com, llvm-bugs@lists.llvm.org,
                    richard-l...@metafoo.co.uk

C++ allows e.g.,  combining (int const(*)[100])x with (int (*)[100])y as in 

 0? (int(*)[100])0 : (int const(*)[100])0

yielding an expression of type int const(*)[100].

The C standard technically disallows this (could be considered a defect in the
standard) but this  kind of combining/conversion is completely harmless and so
GCC only warns about it under -pedantic.

Consequently, under GCC, it is possible to disable these warnings by enclosing
the "offending" code snippets in (__extension__({ ;}).

This doesn't work on clang, because the above elicits a full (rather than just
a pedantic) warning on clang.

Furthermore, the combined type on clang is void* rather than int(*)[100].

The gcc behavior is more useful.

Some examples with comments at: https://gcc.godbolt.org/z/e7sXdB

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to