1// Copyright 2022 The Chromium Authors 2// Use of this source code is governed by a BSD-style license that can be 3// found in the LICENSE file. 4 5// This is a "No Compile Test" suite. 6// http://dev.chromium.org/developers/testing/no-compile-tests 7 8#include "base/strings/string_piece.h" 9 10#include <string> 11 12namespace base { 13 14// Returns a std::string xvalue (temporary object). 15std::string f(); 16 17 18void HoldsDanglingReferenceToString() { 19 [[maybe_unused]] StringPiece piece = f(); // expected-error {{object backing the pointer will be destroyed at the end of the full-expression}} 20} 21 22} // namespace base 23