C++ Logo

std-proposals

Advanced search

[std-proposals] Proposal: -Wverbose-style

From: Jerome Saint-Martin <jerome.saint-martin_at_[hidden]>
Date: Tue, 14 Oct 2025 17:21:41 +0000
Title:
A Warning Against Excessive Verbosity in Code Style
Author:
A concerned minimalist who believes in trusting operator precedence and the elegance of concise expression.
Abstract:
This proposal introduces a new compiler warning category: -Wverbose-style, designed to gently steer developers toward more confident, geek-approved syntax. It targets overly cautious constructs that, while technically correct, lack stylistic flair and betray a fear of trusting the language
Motivation
Modern C++ encourages clarity and safety. However, some developers take this too far, writing code that is syntactically valid but stylistically bloated. Examples include:

  *
Redundant parentheses in logical expressions
  *
Literal comparisons to true or false
  *
Over-commenting obvious constructs
  *
Overly cautious initializations

This proposal aims to gently nudge developers toward more idiomatic and minimalist C++ — not by enforcing correctness, but by celebrating elegance.
2. Examples
✅ Preferred Geeklike Style:
/* clean, readable, confident */
  if (a && b && c) { }
❌ Triggers -Wverbose-style:
// warning: verbose-style detected. Consider trusting operator precedence.
  if ((a && b) && (a && c))
// warning: verbose-style detected. Just write `if (flag)`
  if (flag == true)
warning: verbose-style detected. Consider `std::string{}` or direct usage.
  std::string s = "";
warning: verbose-style detected. Initialization could be more idiomatic.
  int x = 0; // instead of `int x{};`
warning: verbose-style detected. Comment restates the obvious
  if (x > 0) // Check if x is positive
  i++; // Increment i
warning: verbose-style detected. Initialization could be more idiomatic. Consider direct usage
  std::vector<int> v = std::vector<int>();
Implementation
This warning would be opt-in via compiler flag:
g++ -Wverbose-style

Received on 2025-10-14 17:21:44