[llvm-bugs] [Bug 42001] New: incompatible pointer types warning restrict

via llvm-bugs llvm-bugs at lists.llvm.org
Fri May 24 01:54:50 PDT 2019


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: unassignedclangbugs at nondot.org
          Reporter: gonzalobg88 at gmail.com
                CC: blitzrakete at gmail.com, dgregor at apple.com,
                    erik.pilkington at gmail.com, llvm-bugs at lists.llvm.org,
                    richard-llvm at 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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20190524/35f979d5/attachment-0001.html>


More information about the llvm-bugs mailing list