Document number P****R0
Date 2022-09-27

Jarrad J. Waterloo <descender76 at gmail dot com>

Audience Evolution Working Group (EWG)

C++ is the next C++

Table of contents


Programmer’s, Businesses and Government(s) want C++ to be safer and simpler. This has led some C++ programmers to create new programming languages or preprocessors which again is a new language. This paper discusses using static analysis to make the C++ language itself safer and simpler.

Motivating Examples

Following is a wishlist. Most are optional. While, they all would be of benefit. It all starts with a new repeatable module level attribute that would preferably be applied once in the primary module interface unit and would automatically apply to it and all module implementation unit(s). It could also be applied to a module implementation unit but that would generally be less useful. However, it might aid in gradual migration.

export module some_module_name [[static_analysis("")]];// primary module interface unit
// or
module some_module_name [[static_analysis("")]];// module implementation unit

The name of the static analyzer are dotted. Unscoped or names that start with std., c++., cpp., cxx. or c. are reserved for standardization.

This proposal wants to stardardize two overarching static analyzer names; safer and modern.


The safer analyzer is for safety, primarily memory related. It is for those businesses and programmers who must conform to safety standards.


The safer analyzer is a subset of modern analyzer. The modern analyzer goes beyond just memory and safety concerns. It can be thought of as bleeding edge. It is for those businesses and programmers who commit to safety and higher quality modern code.

Neither is concerned about formatting or nitpicking. Both static analyzers only produce errors. They both represent +∞. These are meant for programmers, businesses and governments in which safety takes precedence. When a new version of the standard is released and adds new sub static analyzers than everyone’s code is broken until their code is fixed. These sub static analyzers usually consist of features that have been mostly replaced with some other feature. It would be ideal if the errors produced not only say that the code is wrong but also provide a link to html page(s) maintained by both the C++ teaching group, the authors of the C++ Core Guidelines [1] and compiler specific errors. These pages should provide example(s) of what is being replaced and by what was it replaced. Mentioning the version of the C++ standard would also be helpful.

All modules can be used even if they don’t use the static_analysis attribute as this allows gradual adoption.

What are the safer and modern analyzers composed of?

These overarching static analyzers are composed of multiple static analyzers which can be used individually to allow a degree of gradual adoption.

Use lvalue references


use_lvalue_references is a subset of safer.


lvalue references

1985: Cfront 1.0 [2]


1992 [2:1]

std::unique_ptr, std::shared_ptr, std::weak_ptr, std::reference_wrapper, std::make_shared




std::string_view, std::optional, std::any, std::variant


std::make_shared support arrays, std::span


The C++ Core Guidelines [1:1] identifies issues that this feature helps to mitigate.


Usage of smart pointers

This static analyzer causes programmers to use 2 extra characters when using smart pointers: -> vs (*)..


the main function and environment variables

A shim module is needed in order to transform main and env functions into a more C++ friendly functions. These have been asked for years.

  1. A Modern C++ Signature for main [54]
  2. Desert Sessions: Improving hostile environment interactions [55]

No unsafe casts


no_unsafe_casts is a subset of safer.


See the following:

No unions


no_union is a subset of safer.

Using the union keyword produces an error. It was replaced by std::variant, which is safer.

See the following:

No mutable


no_mutable is a subset of safer.

Using the mutable keyword produces an error. The programmer shall not lie to oneself. The mutable keyword violates the safety of const and is rarely used.

No new or delete


no_new_delete is a subset of safer.

Using the new and delete keywords to allocate and deallocate memory produces an error. It was replaced by std::make_unique and std::make_shared, which are safer.

See the following:

No deprecated


no_deprecated is a subset of modern.

Using anything that has the deprecated attribute on it produces an error.

What may safer and modern analyzers be composed of in the future?

No include


no_include is a subset of modern.

The preprocessor directive #include has been replaced with import.
Don’t add the static analyzer until #embed is added.

No goto


no_goto is a subset of modern.

Using the goto keyword produces an error.
Don’t add until break and continue to a label is added. Also a finite state machine library may be needed.

See the following:


By adding static analysis to the C++ language we can make the language safer and easier to teach because we can restrict how much of the language we use. Human readable errors and references turns the compiler into a teacher freeing human teachers to focus on what the compiler doesn’t handle.

Frequently Asked Questions

Shouldn’t these be warnings instead of errors?

NO, otherwise we’ll be stuck with what we just have. C++ compilers produces plenty of warnings. C++ static analyzers produces plenty of warnings. However, when some one talks about creating a new language, then old language syntax becomes invalid i.e. errors. This is for programmers. Programmers and businesses rarely upgrade their code unless they are forced to. Businesses and Government(s) want errors as well in order to ensure code quality and the assurance that bad code doesn’t exist anywhere in the module. This is also important from a language standpoint because we are essentially pruning; somewhat. Keep in mind though that all of these pruned features still have use now and in the future as more constructs will be built upon them which is why they need to be part of the language just not a part of everyday usage of the language.

Why at the module level? Why not safe and unsafe blocks?

Programmers and businesses rarely upgrade their code unless they are forced to. New programmers need training wheels and some of us older programmers like them too. Due to the proliferation of government regulations and oversight, businesses have acquired software composition analysis services and tools. These services map security errors to specific versions of modules; specifically programming artifacts such as executables and libraries. As such, businesses want to know is a module reasonably safe.

You must really hate pointers?

Actually, I love C, C++ and pointers.

The fact is pointers, unsafe casts, union, mutable and goto are the engine of C++ change. As such it would be foolish to remove them but it is also unrealistic for users/drivers of a vehicle to have to drive with nothing between them and the engine without listening to them clamor for interior finishing.

C++ can’t standardize specific static analyzers


  1. ↩︎ ↩︎

  2. ↩︎ ↩︎

  3. ↩︎

  4. ↩︎

  5. ↩︎

  6. ↩︎

  7. ↩︎

  8. ↩︎

  9. ↩︎

  10. ↩︎

  11. ↩︎

  12. ↩︎

  13. ↩︎

  14. ↩︎

  15. ↩︎

  16. ↩︎

  17. ↩︎

  18. ↩︎

  19. ↩︎

  20. ↩︎ ↩︎

  21. ↩︎ ↩︎

  22. ↩︎

  23. ↩︎

  24. ↩︎

  25. ↩︎

  26. ↩︎

  27. ↩︎

  28. ↩︎ ↩︎

  29. ↩︎ ↩︎

  30. ↩︎ ↩︎

  31. ↩︎

  32. ↩︎

  33. ↩︎

  34. ↩︎

  35. ↩︎

  36. ↩︎ ↩︎

  37. ↩︎

  38. ↩︎

  39. ↩︎

  40. ↩︎

  41. ↩︎ ↩︎

  42. ↩︎ ↩︎

  43. ↩︎ ↩︎

  44. ↩︎

  45. ↩︎

  46. ↩︎

  47. ↩︎

  48. ↩︎

  49. ↩︎ ↩︎

  50. ↩︎ ↩︎

  51. ↩︎

  52. ↩︎

  53. ↩︎

  54. ↩︎

  55. ↩︎

  56. ↩︎

  57. ↩︎

  58. ↩︎

  59. ↩︎

  60. ↩︎

  61. ↩︎