<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - Clang refuses to compile code that other compilers do due to __restrict"
   href="https://bugs.llvm.org/show_bug.cgi?id=38631">38631</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Clang refuses to compile code that other compilers do due to __restrict
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>6.0
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>C++
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedclangbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>dark_sylinc@yahoo.com.ar
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>dgregor@apple.com, llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>I wasn't sure to call this a "bug" because __restrict keyword is supposedly a
compiler extension, so portability is not guaranteed.

However Clang is the only compiler (vs MSVC and GCC) to refuse to build this
simple snippet of code and seems to me this behavior is not really
intended/expected from Clang:

struct Obj
{
    float * __restrict myPtr[2];
};

int main()
{
    Obj a, b;

    a = b;

    return 0;
}

The error is:
main.cpp:742:8: error: cannot initialize a parameter of type 'void *' with an
rvalue of type 'float *__restrict (*)[2]'
struct Obj
       ^~~
../../src/main.cpp:751:7: note: in implicit copy assignment operator for 'Obj'
first required here
    a = b;

Removing the __restrict keyword fixes the problem. Also another way to fix the
problem is to split myPtr[2] into two variables, e.g. myPtr0 and myPtr1

Using __restrict__ instead of __restrict yields the same outcome.

Invocation is:
clang++-6.0 -Wall -Wextra -g -DDEBUG -MD -MT
CMakeFiles/Playground.dir/src/main.cpp.o -MF
CMakeFiles/Playground.dir/src/main.cpp.o.d -o
CMakeFiles/Playground.dir/src/main.cpp.o -c ../../src/main.cpp

clang++-6.0 --version
clang version 6.0.0-1ubuntu2 (tags/RELEASE_600/final)
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>