https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115624

            Bug ID: 115624
           Summary: '-Wnrvo' is not an option that controls warnings
           Product: gcc
           Version: 14.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: albrecht.guendel at web dot de
  Target Milestone: ---

Hi, 
the new -Wnrvo warning is an amazing diagnostic.
However it does not play well with the #pragma GCC diagnostic directive. Yet.

Test-Case: https://godbolt.org/z/Tq8e8zPx8  

For the sake of completeness, here is the code:

using GCC 14.1 with "-Wnrvo" option

#include <string>
#pragma GCC diagnostic ignored "-Wnrvo"

std::string no_nrvo(int i)
{
    std::string ret{};
    if (i % 2)
        return {};
    return ret;
}


Current behavior:
warning: '-Wnrvo' is not an option that controls warnings [-Wpragmas]
warning: not eliding copy on return in 'std::string no_nrvo(int)' [-Wnrvo]

Expected behavior:
accept the "#pragma GCC diagnostic ignored" and do not diagnose the missed
optimization.

Reply via email to