Date
2025-01-21.15:20:36
Message id
7860

Content

(From submission #628.)

A warning is currently, but ought not to be, encouraged for a call to a [[nodiscard]] function with a void return type. Such a situation may arise for dependent return types. For example:

  [[nodiscard]] void f();
  template<class T> [[nodiscard]] T g();

  void h() {
    f();                // suggested change: warning no longer recommended
    (void)f();          // warning not recommended
    g<int>();           // warning recommended
    g<void>();          // suggested change: warning no longer recommended
    (void)g<void>();    // warning not recommended
  }