C++ programmer's guide to undefined behavior: part 3 of 11

Your attention is invited to the third part of an e-book on undefined behavior. This is not a textbook, as it's intended for those who are already familiar with C++ programming. It's a kind of C++ programmer's guide to undefined behavior and to its most secret and exotic corners. The book was written by Dmitry Sviridkin and edited by Andrey Karpov.

C++ programmer's guide to undefined behavior: part 3 of 11

by Dmitry Sviridkin

From the article:

This program, built by GCC 10.1, -std=c++20 -O3, doesn't crash, but it doesn't output anything either. If we take GCC 14.1 and the same keys, we suddenly get "helloworld" in the output. It's old but gold undefined behavior.

CppCon 2024 Irksome C++ -- Walter E Brown

Registration is now open for CppCon 2024! The conference starts on September 15 and will be held in person in Aurora, CO. To whet your appetite for this year’s conference, we’re posting some upcoming talks that you will be able to attend this year. Here’s another CppCon future talk we hope you will enjoy – and register today for CppCon 2024!

Irksome C++

Thursday, September 19 • 16:45 - 17:45 MDT

Walter E Brown

Summary of the talk:

As much as I like C++, it is certainly not free of -- let's say -- quirks.  Both the core language and the standard library exhibit idiosyncracies, sometimes even in conflict with one another.

Some of these "oops" may be historical in origin.  However, most are due to the spectrum of viewpoints held by the hundreds of contributors who have participated in C++ standardization to date.

This talk points out many of these inconsistencies and numerous other infelicities in naming, behavior, or both.  Come see whether *your* pet C++ peeve is mentioned!

 

With broad experience in industry, academia, consulting, and research, Dr. Walter E. Brown has been a computer programmer for almost 60 years, and a C++ programmer for more than 40 years.He joined the C++ standards effort in 2000, and has since written circa 175 proposal papers. Among numerous other contributions, he is responsible for introducing such now-standard C++ library features as cbegin/cend, common_type, gcd/lcm, void_t, and ’s mathematical special functions, as well as the headers and . He has also significantly impacted such C++ core language features as alias templates, contextual conversions, variable templates, static_assert, and operator (the C++20 “spaceship operator”).When not playing with his grandchildren, Dr. Brown continues as an Emeritus participant in the C++ standards process and as a frequent speaker at C++ conferences and meetups worldwide.

CppCon 2024 Building Cppcheck - What We Learned from 17 Years of Development -- Daniel Marjamäki

Registration is now open for CppCon 2024! The conference starts on September 15 and will be held in person in Aurora, CO. To whet your appetite for this year’s conference, we’re posting some upcoming talks that you will be able to attend this year. Here’s another CppCon future talk we hope you will enjoy – and register today for CppCon 2024!

Building Cppcheck - What We Learned from 17 Years of Development

Wednesday, September 18 • 09:00 - 10:00 MDT

by Daniel Marjamäki

Summary of the talk:

Cppcheck has been evolving for 17 years, guided by a clear philosophy: minimal false positives and ease of use. This presentation will share the insights we've gained during its development. Our approach to easy configuration is a double-edged sword, providing user-friendly setup while occasionally leading to lower recall. We maintain a strict definition of false positives, ensuring the tool does not warn about well-written, functional code. This principle, while challenging, drives us to fix rather than suppress false positives. A core philosophy of Cppcheck is to learn from mistakes. When an issue is identified, we strive to implement checkers to prevent similar mistakes in the future.

The open-source community plays a crucial role in Cppcheck's evolution. We collaborate to enhance the tool, scanning large codebases like Debian's source code to identify inconsistent or dangerous code and measure false positives. We also explore how abstractions, compiler annotations, and contracts can improve SCA tools' precision and performance. This talk will provide a comprehensive look at the lessons learned and the continuous improvement of Cppcheck.

 

Daniel Marjamäki is a software engineer from Sweden and the author of Cppcheck, a static analysis tool for C/C++ code. He created Cppcheck to help developers find bugs and improve code quality. Thanks to his work, Cppcheck has become a widely used tool in the programming community. Marjamäki is known for his contributions to improving software development practices.

CppCon 2024 Data Is All You Need for Fusion -- Manya Bansal

Registration is now open for CppCon 2024! The conference starts on September 15 and will be held in person in Aurora, CO. To whet your appetite for this year’s conference, we’re posting some upcoming talks that you will be able to attend this year. Here’s another CppCon future talk we hope you will enjoy – and register today for CppCon 2024!

Data Is All You Need for Fusion

Monday, September 16 • 16:45 - 17:45 MDT

by Manya Bansal

Summary of the talk:

Functions are the fundamental unit of interoperability in software design: users write applications by composing functions provided by various libraries. However, naive function composition can result in poor performance due to memory overheads that exist at function boundaries. Operator fusion --- combining the execution of several operators into one operator --- is a well-known technique to combat this overhead. Previous solutions to add fusion rely on complex, monolithic compilers and languages that force performance engineers to rediscover old solutions in new ecosystems, leading to decades of performance engineering work going underutilized. In this work, I attempt to identify the minimal ingredients required to enable fusion on top of existing library interfaces. In doing so, I propose a lightweight enrichment of function interfaces that exposes data production and consumption patterns of functions. I show how to implement these ideas in C++ and demonstrate the benefits of my system by showing that it is competitive with state-of-the-art high-performance libraries, and that it can fuse across library boundaries for unforeseen workloads.
 

Manya is a computer science PhD student at MIT, advised by Saman Amarasinghe and Jonathan Ragan-Kelley. Before starting her PhD, she studied Mathematics at Stanford University, and worked with Fredrik Kjolstad and Dawson Engler. Manya is interested in designing extensible and productive languages and tools for heterogeneous systems.

Trip Report: C++ On Sea 2024 -- Sandor Dargo

SANDOR_DARGO_ROUND.JPGI had the privilege to attend and present at C++ on Sea 2024 for the 5th time in a row!

Trip Report: C++ On Sea 2024

by Sandor Dargo

From the article:

The conference had a very strong start. Right after the keynote by Dave Abrahams, 4 incredible speakers were on stage at the same time on the 4 different tracks. Jason Turner, Walter E Brown, Nico Josuttis, Mateusz Pusz…

 

If a conference could have these people throughout the whole program, it would already be a strong conference. C++ On Sea proposed such a strong line-up that these people could be scheduled at the same time. It didn’t make my decision easier, so I chose based on the topic, and I wanted to grow my knowledge on constexpr so I stayed in the main() room.

CppCon 2024 Multi Producer, Multi Consumer, Lock Free Atomic Queue -- Erez Strauss

Registration is now open for CppCon 2024! The conference starts on September 15 and will be held in person in Aurora, CO. To whet your appetite for this year’s conference, we’re posting some upcoming talks that you will be able to attend this year. Here’s another CppCon future talk we hope you will enjoy – and register today for CppCon 2024!

Multi Producer, Multi Consumer, Lock Free Atomic Queue

Tuesday, September 17 • 0900 - 10:00 MDT

by Erez Strauss

Summary of the talk:

This presentation introduces a multi-producer, multi-consumer, lock-free queue with unique characteristics. We will cover the C++17 implementation and the std::atomic features required for this queue based on the CPU atomic instructions and discuss the queue's portability across various CPU architectures, beyond just X86_64 and runtime environments.

Efficient message queue-based communication between threads is crucial for optimal performance in multi-threaded applications. Queues are fundamental data structures that interact with various aspects of the application environment, including schedulers, memory allocation systems, and CPU hardware architectures.

Many use cases such as trading platforms, games, audio processing and other fields have strict latency and scaling requirements and this queue implementation has proved to reduce system latencies.

The presentation will feature the design of the queue, the required template language features, bandwidth and latency consideration, and multiple demo applications. Comparing this queue implementation’s benchmark results with other existing queues will follow. Finally, we will discuss potential future work and areas for improvement.

Join us to explore how this innovative queue implementation can improve your multi-threaded application performance.

All presentation materials, including the C++17 source code, slides, benchmarks, and demo applications are available on GitHub.

 

Erez Strauss worked in Banks and Hedge Funds while focused on low latency systems.

CppCon 2024 Many Ways to Kill an Orc (or a Hero) -- Patrice Roy

Registration is now open for CppCon 2024! The conference starts on September 15 and will be held in person in Aurora, CO. To whet your appetite for this year’s conference, we’re posting some upcoming talks that you will be able to attend this year. Here’s another CppCon future talk we hope you will enjoy – and register today for CppCon 2024!

Many Ways to Kill an Orc (or a Hero)

Monday, September 16 • 15:15 - 16:15 MDT

by Patrice Roy

Summary of the talk:

Our game programmers and game engines involve fights between heroes and their foes. There are «classical», traditional ways to express heroes and monsters fighting each other, but contemporary C++ is particularly expressive and versatile language and with out language there are many ways for heroes and monsters to hit at each other. These techniques are what this talk will explore

 

Patrice Roy has been playing with C++, either professionally, for pleasure or (most of the time) both for over 30 years. After a few years doing R&D and working on military flight simulators, he moved on to academics and has been teaching computer science since 1998. Since 2005, he’s been involved more specifically in helping graduate students and professionals from the fields of real-time systems and game programming develop the skills they need to face today’s challenges.He’s been a participating member in the ISO C++ Standards Committee since late 2014 and has been involved with the ISO Programming Language Vulnerabilities since late 2015. He has five kids, and his wife ensures their house is home to a continuously changing numbers of cats, dogs and other animals.

Voting and early bird tickets for Meeting C++ 2024 are available until August 11th

A few weeks ago the voting for Meeting C++ 2024 started, contribute with your own voting session to the program selection of this years Meeting C++!

Also, as the most recent announcement, early bird tickets are on sale until August 11th, the day the voting ends:

Early Bird Tickets for Meeting C++ 2024 are available until August 11!

by Jens Weller

From the article:

Quick reminder that the early bird tickets for Meeting C++ 2024 are going to be availble until the end of the voting on the talks!

Which is August 11th! Its also possible that early bird tickets sell out before this. Currently only the hotel ticket and the online ticket are available as early bird. The onsite early bird ticket sold out a few weeks ago.

 

CppCon 2024 So You Think You Can Hash -- Victor Ciura

Registration is now open for CppCon 2024! The conference starts on September 15 and will be held in person in Aurora, CO. To whet your appetite for this year’s conference, we’re posting some upcoming talks that you will be able to attend this year. Here’s another CppCon future talk we hope you will enjoy – and register today for CppCon 2024!

So You Think You Can Hash

Monday, September 16 • 14:00 - 15:00 MDT

by Victor Ciura

Summary of the talk:

Hashing is crucial for efficient data retrieval and storage. This presentation delves into computing hashes for aggregated user-defined types and experimenting with various hash algorithms. We will explore the essentials of hash functions and their properties, techniques for hashing complex user-defined types, and customizing std::hash for specialized needs.

Additionally, we (re)introduce a framework for experimenting with and benchmarking different hash algorithms. This will allow easy switching of hashing algorithms used by complex data structures, enabling easy comparisons. Hash algorithm designers can concentrate on designing better hash algorithms, with little worry about how these new algorithms can be incorporated into existing code. Type designers can create their hash support just once, without worrying about what hashing algorithm should be used.

You will gain practical insights and tools to implement, customize, and evaluate hash functions in C++, enhancing software performance and reliability.

 

Victor Ciura is a Principal Engineer on the Visual C++ team, helping to improve the tools he’s been using for years. Leading engineering efforts across multiple teams working on making Visual Studio the best IDE for C++ Game developers.   Before joining Microsoft, he programmed C++ professionally for 20 years, designing and implementing several core components & libraries of Advanced Installer, improving the virtualization and repackaging technologies for MSI/MSIX.   One of his hobbies is tidying-up and modernizing aging codebases and has been known to build open-source tools that help this process: Clang Power Tools.   He’s a regular guest at Computer Science Department of his Alma Mater, University of Craiova, where he gives student lectures & workshops on using modern C++, STL, algorithms and optimization techniques.   More details: @ciura_victor & https://ciura.ro & linkedin.com/in/victor-ciura

What’s the point of std::monostate? You can’t do anything with it! -- Raymond Chen

RaymondChen_5in-150x150.jpgC++17 introduced std::monostate, a dummy type with no members and trivial functions, primarily used when no action is needed. Despite its simplicity, std::monostate plays a crucial role in scenarios like coroutines and std::variant, where a default-constructible placeholder type is required.

What’s the point of std::monostate? You can’t do anything with it!

by Raymond Chen

From the article:

C++17 introduced std::monostate, and I used it as a placeholder to represent the results of a coroutine that produces nothing. In the comments, Neil Rashbrook asked what you are expected to do with a std::monostate, seeing as has no members and only trivial member functions.

The answer is “nothing”.

The purpose of std::monostate is to be a dummy type that does nothing. All instances are considered equal to each other. It is basically this:

struct monostate {};
// plus relational operators and a hash specialization

You can see it in libcxx (LLVM/clang)libstdc++ (gcc), and stl (msvc).