From c79fa47aac9b38865dab5e9f29030903bf460c46 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A1s=20P=C5=91cze?= Date: Mon, 27 May 2024 13:24:29 +0000 Subject: android: camera_capabilities: Fix GCC 14 warning MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit GCC 14 thinks `rects` is a "possibly dangling reference to a temporary": /libcamera/src/android/camera_capabilities.cpp: In member function ‘int CameraCapabilities::initializeStaticMetadata()’: /libcamera/src/android/camera_capabilities.cpp:1084:46: error: possibly dangling reference to a temporary [-Werror=dangling-reference] 1084 | const Span& rects = | ^~~~~ /libcamera/src/android/camera_capabilities.cpp:1085:83: note: the temporary was destroyed at the end of the full expression ‘(& properties)->libcamera::ControlList::get >(libcamera::properties::PixelArrayActiveAreas).std::optional >::value_or >(libcamera::Span())’ 1085 | properties.get(properties::PixelArrayActiveAreas).value_or(Span{}); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~ The return value of `value_or()` is indeed a temporary, but binding it to a reference extends its lifetime. Avoid the warning by not using a reference; this does not make much difference since `value_or()` does not return a reference. Signed-off-by: Barnabás Pőcze Reviewed-by: Kieran Bingham Reviewed-by: Laurent Pinchart Signed-off-by: Laurent Pinchart --- src/android/camera_capabilities.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/android') diff --git a/src/android/camera_capabilities.cpp b/src/android/camera_capabilities.cpp index 6f4d48de..71043e12 100644 --- a/src/android/camera_capabilities.cpp +++ b/src/android/camera_capabilities.cpp @@ -1081,7 +1081,7 @@ int CameraCapabilities::initializeStaticMetadata() } { - const Span &rects = + const Span rects = properties.get(properties::PixelArrayActiveAreas).value_or(Span{}); std::vector data{ static_cast(rects[0].x), -- cgit v1.2.1