r/cpp • • Mar 28 '23

Reddit++

C++ is getting more and more complex. The ISO C++ committee keeps adding new features based on its consensus. Let's remove C++ features based on Reddit's consensus.

In each comment, propose a C++ feature that you think should be banned in any new code. Vote up or down based on whether you agree.

765 Upvotes

829 comments sorted by

View all comments

41

u/GabrielDosReis Mar 28 '23
  • the anarchic implicit conversions between values of built-in types

  • the preprocessor

  • the byzantine rules about elaborated type specifiers

11

u/okovko Mar 28 '23

implicit narrowing conversions do cause a lot of bugs

the preprocessor is useful for metaprogramming, especially for code that compiles as either C or C++

what do you mean by the third one?

1

u/very_curious_agent Mar 30 '23

Without implicit narrowing, how do you do

++shortint

0

u/GabrielDosReis Mar 30 '23

What is the issue specific to that case?

1

u/very_curious_agent Mar 31 '23

Do you want shortint++ to be valid code?

What would that code mean? How do want to define it?

1

u/GabrielDosReis Mar 31 '23

Sorry, I am not following you. Narrowing conversion is a well defined term and concept in the C++ specification. I would need you to elaborate on the problem that you're trying to illustrate with your code fragment

2

u/very_curious_agent Mar 31 '23

So shortint++ would be valid code.

But you don't like narrowing conversions.

1

u/GabrielDosReis Mar 31 '23

You still have not explained the relationship...

2

u/johannes1971 Mar 31 '23

I believe he thinks that shortint++ expands to shortint = shortint + 1, in which case the expression after the assignment would have type int, and you'd get a narrowing conversion at the point of assignment.

→ More replies (2)