[llvm-bugs] [Bug 47234] New: clang cannot initialize a variable of type 'double (*)[a][b]' with an rvalue of type 'double (*)[a][b]'

via llvm-bugs llvm-bugs at lists.llvm.org
Wed Aug 19 06:40:30 PDT 2020


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

            Bug ID: 47234
           Summary: clang cannot initialize a variable of type 'double
                    (*)[a][b]' with an rvalue of type 'double (*)[a][b]'
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: C++
          Assignee: unassignedclangbugs at nondot.org
          Reporter: tangyixuan at mail.dlut.edu.cn
                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

Clang++ rejects the following code while g++ accepts.

$ cat s.C

#include<stdio.h>
#include<stdlib.h>

int a,b;

void f(double *x1)
{
  double (*x2)[a][b]=(double(*)[a][b])x1;
}

int main()
{ double *data;
  a=100;
  b=100;
  data=(double*)malloc(a*b*sizeof(double));
  f(data,0);
  return 0;
}

$ clang++ -c s.C
s.C:8:12: error: cannot initialize a variable of type 'double (*)[a][b]' with
an rvalue of type 'double (*)[a][b]'
  double (*x2)[a][b]=(double(*)[a][b])x1;
           ^         ~~~~~~~~~~~~~~~~~~~
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/20200819/d3099bfb/attachment.html>


More information about the llvm-bugs mailing list