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

            Bug ID: 42001
           Summary: incompatible pointer types warning restrict
           Product: clang
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: C
          Assignee: unassignedclangb...@nondot.org
          Reporter: gonzalob...@gmail.com
                CC: blitzrak...@gmail.com, dgre...@apple.com,
                    erik.pilking...@gmail.com, llvm-bugs@lists.llvm.org,
                    richard-l...@metafoo.co.uk

This:

int foo() {
    int * const restrict * restrict f = 0;
    int * const * b = 0;
    f = b;
        b = f;

    return 0;
}

int bar() {
    typedef int(*foo)(int * const restrict * restrict);
    typedef int(*bar)(int * const *);
    foo f = 0;
    bar b = 0;
    f = b;
    b = f;

    return 0;
}

produces (godbolt: https://godbolt.org/z/gvUZfc) these warnings:

<source>:5:4: warning: assigning to 'int *const *' from 'int *const restrict
*restrict' discards qualifiers
[-Wincompatible-pointer-types-discards-qualifiers]

        b = f;

          ^ ~

<source>:15:7: warning: incompatible function pointer types assigning to 'foo'
(aka 'int (*)(int *const restrict *restrict)') from 'bar' (aka 'int (*)(int
*const *)') [-Wincompatible-function-pointer-types]

    f = b;

      ^ ~

<source>:16:7: warning: incompatible function pointer types assigning to 'bar'
(aka 'int (*)(int *const *)') from 'foo' (aka 'int (*)(int *const restrict
*restrict)') [-Wincompatible-function-pointer-types]

    b = f;

---

I'm not sure how "incompatible" these pointers really are, but I expect a
restrict pointer to implicitly coerce to a non-restrict one at least. Like, in
this example:

int foo() {
    int * const * f = 0;
    int * * b = 0;
    f = b;

    return 0;
}

no warnings are produced.

-- 
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