{"id":39055,"date":"2023-04-13T15:03:00","date_gmt":"2023-04-13T19:03:00","guid":{"rendered":"https:\/\/mjtsai.com\/blog\/?p=39055"},"modified":"2023-04-13T15:03:00","modified_gmt":"2023-04-13T19:03:00","slug":"c23-standard-sets-the-world-on-fire","status":"publish","type":"post","link":"https:\/\/mjtsai.com\/blog\/2023\/04\/13\/c23-standard-sets-the-world-on-fire\/","title":{"rendered":"C23 Standard Sets the World on Fire"},"content":{"rendered":"<p><a href=\"https:\/\/queue.acm.org\/detail.cfm?id=3588242\">Terence Kelly and Borer Yekai Pan<\/a> (via <a href=\"https:\/\/news.ycombinator.com\/item?id=35404025\">Hacker News<\/a>):<\/p>\n<blockquote cite=\"https:\/\/queue.acm.org\/detail.cfm?id=3588242\">\n<p>Like the previous major revision, C11, the latest standard introduces several useful features. The most important, if not the most exciting, make it easier to write safe, correct, and secure code. For example, the new <code>&lt;stdckdint.h&gt;<\/code> header standardizes <i>checked integer arithmetic<\/i>[&#8230;]<\/p>\n<p>[&#8230;]<\/p>\n<p>In addition to these new correctness and safety aids, C23 provides many new conveniences: Constants <code>true<\/code>, <code>false<\/code>, and <code>nullptr<\/code> are now language keywords; mercifully, they mean what you expect. The new <code>typeof<\/code> feature makes it easier to harmonize variable declarations. The preprocessor can now <code>#embed<\/code> arbitrary binary data in source files. Zero-initializing stack-allocated structures and variable-length arrays is a snap with the new standard <code>={}<\/code> syntax.<\/p>\n<p>[&#8230;]<\/p>\n<p>Standard C hides behind a paywall: The official standard currently costs more than $200, so most coders make do with unofficial drafts. The standard routinely confuses its own authors, and crucial parts mystify even experienced and well-educated programmers; baffled silence is not consent.<\/p>\n<p>[&#8230;]<\/p>\n<p>C23 furthermore gives the compiler license to use an <code>unreachable<\/code> annotation on one code path to justify removing, without notice or warning, an entirely <i>different<\/i> code path that is <i>not<\/i> marked <code>unreachable<\/code>[&#8230;]<\/p>\n<p>[&#8230;]<\/p>\n<p>Imagine, then, my dismay when I learned that C23 declares <code>realloc(ptr,0)<\/code> to be undefined behavior, thereby pulling the rug out from under a widespread and exemplary pattern deliberately condoned by C89 through C11.<\/p>\n<\/blockquote>\n\n<p>Previously:<\/p>\n<ul>\n<li><a href=\"https:\/\/mjtsai.com\/blog\/2022\/08\/19\/c23-is-finished\/\">C23 Is Finished<\/a><\/li>\n<\/ul>","protected":false},"excerpt":{"rendered":"<p>Terence Kelly and Borer Yekai Pan (via Hacker News): Like the previous major revision, C11, the latest standard introduces several useful features. The most important, if not the most exciting, make it easier to write safe, correct, and secure code. For example, the new &lt;stdckdint.h&gt; header standardizes checked integer arithmetic[&#8230;] [&#8230;] In addition to these [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"apple_news_api_created_at":"2023-04-13T19:03:02Z","apple_news_api_id":"743dfd3a-5424-4d55-80a4-c74e8643a5fd","apple_news_api_modified_at":"2023-04-13T19:03:03Z","apple_news_api_revision":"AAAAAAAAAAD\/\/\/\/\/\/\/\/\/\/w==","apple_news_api_share_url":"https:\/\/apple.news\/AdD39OlQkTVWApMdOhkOl_Q","apple_news_coverimage":0,"apple_news_coverimage_caption":"","apple_news_is_hidden":false,"apple_news_is_paid":false,"apple_news_is_preview":false,"apple_news_is_sponsored":false,"apple_news_maturity_rating":"","apple_news_metadata":"\"\"","apple_news_pullquote":"","apple_news_pullquote_position":"","apple_news_slug":"","apple_news_sections":"\"\"","apple_news_suppress_video_url":false,"apple_news_use_image_component":false,"footnotes":""},"categories":[4],"tags":[45,164,863,46,138,71,48],"class_list":["post-39055","post","type-post","status-publish","format-standard","hentry","category-programming-category","tag-c","tag-documentation","tag-integer-overflow","tag-languagedesign","tag-optimization","tag-programming","tag-security"],"apple_news_notices":[],"_links":{"self":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/39055","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/comments?post=39055"}],"version-history":[{"count":1,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/39055\/revisions"}],"predecessor-version":[{"id":39056,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/39055\/revisions\/39056"}],"wp:attachment":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/media?parent=39055"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/categories?post=39055"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/tags?post=39055"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}