diff options
author | Faisal Vali <faisalv@yahoo.com> | 2013-12-14 00:40:05 +0000 |
---|---|---|
committer | Faisal Vali <faisalv@yahoo.com> | 2013-12-14 00:40:05 +0000 |
commit | 57ae056a5c0d616ee3fd1d8136b74c2854a68a60 (patch) | |
tree | 69f71e858ac29da480b2cfd73df5036410b14607 /clang/test/CodeGenCXX/cxx11-initializer-array-new.cpp | |
parent | e0628c4bf2dd0499930e947ad24d131f0acaf648 (diff) | |
download | bcm5719-llvm-57ae056a5c0d616ee3fd1d8136b74c2854a68a60.tar.gz bcm5719-llvm-57ae056a5c0d616ee3fd1d8136b74c2854a68a60.zip |
Quick-Fix pointer arithmetic when performing multi-D new-array initialization.
clang still doesn't emit the right llvm code when initializing multi-D arrays it seems.
For e.g. the following code would still crash for me on Windows 7, 64 bit:
auto f4 = new int[100][200][300]{{{1,2,3}, {4, 5, 6}}, {{10, 20, 30}}};
It seems that the final new loop that iterates through each outermost array and memsets it to zero gets confused with its final ptr arithmetic.
This patch ensures that it converts the pointer to the allocated type (int [200][300]) before incrementing it (instead of using the base type: 'int').
Richard somewhat squeamishly approved the patch (as a quick fix to potentially make it into 3.4) - while exhorting for a more optimized fix in the future. http://llvm-reviews.chandlerc.com/D2398
Thanks Richard!
llvm-svn: 197294
Diffstat (limited to 'clang/test/CodeGenCXX/cxx11-initializer-array-new.cpp')
-rw-r--r-- | clang/test/CodeGenCXX/cxx11-initializer-array-new.cpp | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/clang/test/CodeGenCXX/cxx11-initializer-array-new.cpp b/clang/test/CodeGenCXX/cxx11-initializer-array-new.cpp index 23577bec661..8de88dcefb0 100644 --- a/clang/test/CodeGenCXX/cxx11-initializer-array-new.cpp +++ b/clang/test/CodeGenCXX/cxx11-initializer-array-new.cpp @@ -99,8 +99,9 @@ void *q = new S[n][3]{ { 1, 2, 3 }, { 4, 5, 6 } }; // CHECK: icmp eq %[[S]]* %[[NEXT_INNER]], %[[END_INNER]] // CHECK: br i1 // -// CHECK: %[[NEXT_OUTER:.*]] = getelementptr %[[S]]* %{{.*}}, i32 1 -// CHECK: icmp eq %[[S]]* %[[NEXT_OUTER]], %[[END_AS_S]] +// CHECK: %[[NEXT_OUTER:.*]] = getelementptr [3 x %[[S]]]* %{{.*}}, i32 1 +// CHECK: %[[NEXT_OUTER_AS_S:.*]] = bitcast [3 x %[[S]]]* %[[NEXT_OUTER]] to %[[S]]* +// CHECK: icmp eq %[[S]]* %[[NEXT_OUTER_AS_S]], %[[END_AS_S]] // CHECK: br i1 // // CHECK: } |