Feature: Software and tools
one side to the other, both are converted to a time unit that is a common fraction between the two. Tis means that their values can only be multiplied. Yet the multiplication required to establish this common representation can result in large numbers where floating-point representations may begin to lose precision. Tis is a common issue, particularly when most implementations count time in nanoseconds. Solid Sands has found that the C++
“Although tuples offer significant
advantages, they are not natively part of the C++ language itself. Instead, they reside in the C++ standard library under the <tuple> header”
is part of C++’s type system but can quickly become complex, especially when implicit conversions are involved. If the programme can’t unambiguously resolve the constructor, the result is a compilation error. SuperGuard addresses these complexities
through meticulously craſted tests that ensure overload resolution selects the intended constructor, providing confidence that tuple construction behaves correctly under all scenarios. In automotive systems, where functionality must be thoroughly validated before deployment, relying on such tools is essential. SuperGuard ensures that tests for C++ tuple constructors are not only thorough but also unambiguous. It handles all the details of constructor resolution, so developers don’t need to worry about unexpected behaviours or errors when dealing with complex tuple types. What makes SuperGuard particularly
useful in automotive testing is its ability to simulate various constructor scenarios, ensuring that all edge cases are covered. For instance, in the example where a tuple
is constructed from a convertible type A, SuperGuard makes sure that the correct constructor is selected, taking into account both explicit and implicit conversions. Without this careful attention to detail, testing might miss critical issues or lead to inconclusive results.
Time conversions and floating- point pitfalls in <chrono> Te <chrono> header provides users with ways to implicitly convert between their own time representation and the implementation-defined representation used by <chrono> clocks. For instance, a query to “wait for 0.0025s” is converted with little to no effort to “2,500,000ns” to interface with a clock. Te straightforward way to perform
these conversions is to compute them directly. Tis is inherently a lossy operation, a limitation that is well documented by the C++ standard. During comparisons between differently represented points in time, <chrono> attempts to ensure greater accuracy with an additional step. Instead of converting
18 September 2025
www.electronicsworld.co.uk
standard and most implementations overlook this quirk in the floor() function when using floats. Te floor() function converts a time point from one representation to another and rounds it down. Te result must be the latest representable time point that is not later than the original. Tis is asserted using an operator, which converts operands to a common representation. If the implementation does not account for the potential loss of precision, the next representable time aſter rounding down may become equal to the original – even if it is larger in theory. Te post-condition of floor() would then be violated. Tis issue, as well as others, is revealed
through the use of a tool like SuperGuard. It causes subtle differences in results and appears seemingly arbitrarily in specific use cases and configurations. Because such discrepancies are not explicitly documented in the function specifications, they can easily go unnoticed, which is a serious concern in safety-critical systems.
Correct implementation Te complexities of constructor resolution and type conversions pose challenges, especially in safety-critical systems. Indeed, <tuple> primarily provides performance and ergonomic benefits; nevertheless, ensuring its correct implementation remains crucial. With SuperGuard, every case is thoroughly considered, documented and tested. SuperGuard handles the fine-grained details, giving engineers peace of mind when using the <tuple> and <chrono> headers in a safety-critical projects.
Page 1 |
Page 2 |
Page 3 |
Page 4 |
Page 5 |
Page 6 |
Page 7 |
Page 8 |
Page 9 |
Page 10 |
Page 11 |
Page 12 |
Page 13 |
Page 14 |
Page 15 |
Page 16 |
Page 17 |
Page 18 |
Page 19 |
Page 20 |
Page 21 |
Page 22 |
Page 23 |
Page 24 |
Page 25 |
Page 26 |
Page 27 |
Page 28 |
Page 29 |
Page 30 |
Page 31 |
Page 32 |
Page 33 |
Page 34 |
Page 35 |
Page 36 |
Page 37 |
Page 38 |
Page 39 |
Page 40 |
Page 41 |
Page 42 |
Page 43 |
Page 44