> -fallocation-dce removes unneeded pairs of new and delete operators
> -fno-allocation-dce Do not remove unused C++ allocations in dead code elimination.
Nice!
> -fanalyzer enables a new static analysis pass and associated warnings [...] analysis of non-C code is unlikely to work.
I'm super excited to see what this does, we need way more static analysis for C! Does anyone know any good static analysers other than gcc's or clang's?
> -Wstring-compare, enabled by -Wextra, warns about equality and inequality expressions between zero and the result of a call to either strcmp and strncmp that evaluate to a constant as a result of the length of one argument being greater than the size of the array pointed to by the other
Again, more (static) analysis and compile-time stuff is super nice!
> -Wzero-length-bounds, enabled by -Warray-bounds, warns about accesses to elements of zero-length arrays that might overlap other members of the same object.
Hell yes! Scary that this wasn't already a thing?
All the other improvements to warnings are incredibly useful, too!
> Extended characters in identifiers may now be specified directly in the input encoding
> get_naïve_pi
Why...?
C2x revision:
> The [[]] attribute syntax is supported, as in C++.
I always have to look up the old one. What is it, __attribute, __attribute__, _attribute_, attribute, ...?
C++ 20:
> P1301R4, [[nodiscard("with reason")]]
Awesome, will use this right away!
> P0912R5, Coroutines (requires -fcoroutines)
> P0784R7, constexpr new
Exciting! Will have to learn these now :D
C++ 2a:
> std::span, std::atomic_ref and std::atomic<floating point>, std::ssize, std::to_array, std::construct_at, std::destroy, constexpr std::allocator.
Mathematical constants in <numbers>
And so many more! I'm very excited to use all these, when they're eventually supported by more platforms!
5 comments
[ 173 ms ] story [ 577 ms ] thread> -fallocation-dce removes unneeded pairs of new and delete operators
> -fno-allocation-dce Do not remove unused C++ allocations in dead code elimination.
Nice!
> -fanalyzer enables a new static analysis pass and associated warnings [...] analysis of non-C code is unlikely to work.
I'm super excited to see what this does, we need way more static analysis for C! Does anyone know any good static analysers other than gcc's or clang's?
> -Wstring-compare, enabled by -Wextra, warns about equality and inequality expressions between zero and the result of a call to either strcmp and strncmp that evaluate to a constant as a result of the length of one argument being greater than the size of the array pointed to by the other
Again, more (static) analysis and compile-time stuff is super nice!
> -Wzero-length-bounds, enabled by -Warray-bounds, warns about accesses to elements of zero-length arrays that might overlap other members of the same object.
Hell yes! Scary that this wasn't already a thing? All the other improvements to warnings are incredibly useful, too!
> Extended characters in identifiers may now be specified directly in the input encoding
> get_naïve_pi
Why...?
C2x revision: > The [[]] attribute syntax is supported, as in C++.
I always have to look up the old one. What is it, __attribute, __attribute__, _attribute_, attribute, ...?
C++ 20:
> P1301R4, [[nodiscard("with reason")]]
Awesome, will use this right away!
> P0912R5, Coroutines (requires -fcoroutines)
> P0784R7, constexpr new
Exciting! Will have to learn these now :D
C++ 2a:
> std::span, std::atomic_ref and std::atomic<floating point>, std::ssize, std::to_array, std::construct_at, std::destroy, constexpr std::allocator. Mathematical constants in <numbers>
And so many more! I'm very excited to use all these, when they're eventually supported by more platforms!
Visual C++ as well, because since the XP SP2 issues, Microsoft has come up with SAL, which you can also use on your own code,
https://docs.microsoft.com/en-us/cpp/code-quality/using-sal-...
Then specialized tooling just for this purpose, just two examples,
https://scan.coverity.com/
https://www.sonarqube.org/features/multi-languages/cpp/
Regarding C, I would really like some kind of -fsafe-mode, but I guess we need to contend with -Wall -Werror and -fanalyse.
;)