[LLVMbugs] [Bug 24259] New: Cannot initialize variable with rvalue of same type?

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Fri Jul 24 15:38:16 PDT 2015


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

            Bug ID: 24259
           Summary: Cannot initialize variable with rvalue of same type?
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: Frontend
          Assignee: unassignedclangbugs at nondot.org
          Reporter: paul_robinson at playstation.sony.com
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

$ cat t.cpp
void foo() {
  int s = 4;
  int b[1][s];
  int (*p)[s] = b + 1;
}
$ clang -x c -c t.cpp
$ clang -x c++ -c t.cpp
t.cpp:4:9: error: cannot initialize a variable of type 'int (*)[s]' with an
      rvalue of type 'int (*)[s]'
  int (*p)[s] = b + 1;
        ^       ~~~~~
1 error generated.


VLAs are not part of C++ but Clang claims to support them if everything
is nicely POD-like.
http://clang.llvm.org/compatibility.html#vla

If I take out the "+ 1" C mode is still fine but C++ mode gets:

t.cpp:4:9: error: cannot initialize a variable of type 'int (*)[s]' with an
      lvalue of type 'int [1][s]'
  int (*p)[s] = b;
        ^       ~
1 error generated.

-- 
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/20150724/9d1ee796/attachment.html>


More information about the llvm-bugs mailing list