LEWG [[nodiscard]] policy

Document number: P3201R1
Date: 2024-03-22
Authors: Jonathan Wakely <cxx@kayari.org>, David Sankel <dsankel@adobe.com>, Darius Neațu <dariusn@adobe.com>
Audience: Library Evolution

Introduction

This paper is a conclusion due to a direction poll taken by LEWG in Tokyo 2024. Discussions related to P3162R0 and P3122R1 led to an alternative and simpler policy. More context, introduction, and rationale can be found in the mentioned papers.

LEWG Tokyo 2024 direction poll

POLL: We prefer not having any [[nodiscard]] in upcoming proposals to the standard, and also avoid recommendations to implementors in the standard.

SF WF N WA SA
21 10 2 1 0

Attendance: 27 + 11

Outcome: Consensus in favor (Strongest consensus)

Wording for SD-9

Append to List of Standard Library Policies section of SD-9 (P2267R1: Library Evolution Policies):

X. (P3201R1) [[nodiscard]] policy: Library wording should not use [[nodiscard]].

Rationale: Warnings are non-normative so [[nodiscard]] placement has a spurious impact. Furthermore, implementors are better qualified to identify when and where to emit warnings for their implementations.

References