What's an example of a realistic bug that [[nodiscard_scope]] would catch but [[nodiscard]] wouldn't?

On Fri, Jun 30, 2023 at 12:46 AM Frederick Virchanza Gotham via Std-Proposals <std-proposals@lists.isocpp.org> wrote:
If we want a function's return value not to be discarded, we mark it
with [[nodiscard]].

In the case of 'std::synchronized_value', the method 'synchronize'
returns an object that's intended to become a local object, as in:

std::synchronized_value<MyClass> g_obj;

int main(void)
    auto mylock = g_obj.synchronize();


So maybe we should have a new attribute [[nodiscard_scope]] to
indicate that the return value should become a local object in the
calling function.
Std-Proposals mailing list