Commit aad9446
committed
Fix SmallArray with size 0
The original breakage comes from SmallBase<T, Dimv> a couple commits ago. When I
removed the Dimv dependence, it made the base class of every SmallArray<T> the
same no matter the T, which resulted in a padding bug. But removing the base
class entirely makes sizeof(SmallArray)=0 for size 0, which is an
inconvenience. For example, one can't create a std::vector of such objects.
Options are to 1) use a special object for size 0, or reuse std::array, which
does that; or to 2) add a member or a base class that'll take space only when
the size is 0. But now I know why.
* ra/small.hh (SmallArray): As stated.
* test/sizeof.cc: Add test.
Elsewhere use SmallArray::data() in a few places instead of .cp directly.1 parent 045d244 commit aad9446
4 files changed
+34
-35
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
493 | 493 | | |
494 | 494 | | |
495 | 495 | | |
496 | | - | |
| 496 | + | |
| 497 | + | |
497 | 498 | | |
498 | | - | |
499 | | - | |
500 | | - | |
501 | | - | |
502 | | - | |
503 | | - | |
504 | | - | |
505 | | - | |
506 | | - | |
507 | | - | |
508 | | - | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
509 | 502 | | |
510 | 503 | | |
511 | 504 | | |
512 | 505 | | |
513 | | - | |
| 506 | + | |
514 | 507 | | |
515 | 508 | | |
516 | 509 | | |
| |||
521 | 514 | | |
522 | 515 | | |
523 | 516 | | |
524 | | - | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
525 | 520 | | |
526 | 521 | | |
527 | 522 | | |
528 | | - | |
529 | | - | |
| 523 | + | |
| 524 | + | |
530 | 525 | | |
531 | | - | |
| 526 | + | |
532 | 527 | | |
533 | 528 | | |
534 | 529 | | |
| |||
558 | 553 | | |
559 | 554 | | |
560 | 555 | | |
561 | | - | |
562 | 556 | | |
563 | 557 | | |
564 | 558 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
| 2 | + | |
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
19 | | - | |
| 19 | + | |
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| |||
64 | 64 | | |
65 | 65 | | |
66 | 66 | | |
| 67 | + | |
67 | 68 | | |
68 | 69 | | |
69 | 70 | | |
| |||
102 | 103 | | |
103 | 104 | | |
104 | 105 | | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
105 | 122 | | |
106 | 123 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
535 | 535 | | |
536 | 536 | | |
537 | 537 | | |
538 | | - | |
| 538 | + | |
539 | 539 | | |
540 | 540 | | |
541 | | - | |
| 541 | + | |
542 | 542 | | |
543 | 543 | | |
544 | 544 | | |
545 | | - | |
| 545 | + | |
546 | 546 | | |
547 | 547 | | |
548 | 548 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
47 | 47 | | |
48 | 48 | | |
49 | 49 | | |
50 | | - | |
51 | | - | |
52 | | - | |
53 | | - | |
54 | | - | |
55 | | - | |
56 | | - | |
57 | | - | |
58 | | - | |
59 | | - | |
60 | | - | |
61 | | - | |
62 | 50 | | |
63 | 51 | | |
64 | 52 | | |
| |||
0 commit comments