Commit 74cab54
When in-place new-ing a local variable of an array of trivial type, the
generated code calls 'memset' with the correct size of the array,
earlier it was generating size (squared of the typedef array + size).
The cause: typedef TYPE TArray[8]; TArray x; The type of declarator is
Tarray[8] and in SemaExprCXX.cpp::BuildCXXNew we check if it's of
typedef and of constant size then we get the original type and it works
fine for non-dependent cases.
But in case of template we do TreeTransform.h:TransformCXXNEWExpr and
there we again check the allocated type which is TArray[8] and it stays
that way, so ArraySize=(Tarray[8] type, alloc Tarray[8*type]) so the
squared size allocation.
ArraySize gets calculated earlier in TreeTransform.h so that
if(!ArraySize) condition was failing.
fix: I changed that condition to if(ArraySize).
fixes #41441
---------
Co-authored-by: erichkeane <[email protected]>
1 parent 282ab54 commit 74cab54
File tree
4 files changed
+47
-2
lines changed- clang
- docs
- lib
- Sema
- Serialization
- test/SemaCXX
4 files changed
+47
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
557 | 557 | | |
558 | 558 | | |
559 | 559 | | |
| 560 | + | |
560 | 561 | | |
561 | 562 | | |
562 | 563 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12943 | 12943 | | |
12944 | 12944 | | |
12945 | 12945 | | |
| 12946 | + | |
| 12947 | + | |
| 12948 | + | |
| 12949 | + | |
| 12950 | + | |
| 12951 | + | |
| 12952 | + | |
| 12953 | + | |
| 12954 | + | |
| 12955 | + | |
| 12956 | + | |
| 12957 | + | |
| 12958 | + | |
12946 | 12959 | | |
12947 | 12960 | | |
12948 | 12961 | | |
| |||
13004 | 13017 | | |
13005 | 13018 | | |
13006 | 13019 | | |
13007 | | - | |
13008 | 13020 | | |
13009 | 13021 | | |
13010 | 13022 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5097 | 5097 | | |
5098 | 5098 | | |
5099 | 5099 | | |
5100 | | - | |
| 5100 | + | |
5101 | 5101 | | |
5102 | 5102 | | |
5103 | 5103 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
0 commit comments