Composite Array Types in C
summary
C’s composite-type rules cause surprising undefined behavior when array sizes come from runtime or unevaluated expressions: unevaluated VLA size creates UB (examples show arrays like 10 vs runtime n, and mismatched 8 vs 7), and conditional operators plus tentative definitions trigger it. C23/C2Y changes reclassify many cases as diagnostics or constraints so that C23 makes it a constraint violation and composite rules differ for conditional operators and prototypes, reducing but not eliminating pitfalls.
AI-written summary · about
chapters (20)
- 0:00Introduction
- 1:27Arrays in C basics
- 3:37Composite types in C
- 5:02Composite types explained
- 7:27Tentative definitions
- 10:20Defects in prototype rules
- 11:27Array size specifications
- 13:36VLAs and undefined behavior
- 16:34Unspecified/unknown lengths
- 17:36Flexible array members
- 18:39Constant vs variable length
- 20:11C23 composite rules
- 21:17Known constant length arrays
- 22:43Undefined behavior in mismatches
- 26:47VLAs composite types
- 28:15Undefined behavior unequal sizes
- 31:13Unspecified length arrays
- 32:00C23 array rules summary
- 33:47Avoiding pitfalls
- 36:38Q&A
related talks
51mC++ Features You Might Not Know
01h 28mProgramming in Modern C with a Sneak Peek into C23
46mFlexible Array Transformations and Array-bounds Checking
53mC++ Features You Might Not Know
52mNon-conforming C++: the Secrets the Committee Is Hiding From You
29mintegral types
01h 00m"New" Features in C
15mC++ WAT
