From patchwork Tue May 12 14:18:40 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 26737 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id CC701BDCBD for ; Tue, 12 May 2026 14:18:43 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 19BB36301E; Tue, 12 May 2026 16:18:43 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="VlIhGuBE"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 338936271A for ; Tue, 12 May 2026 16:18:42 +0200 (CEST) Received: from killaraus.ideasonboard.com (2001-14ba-70f3-e800--a06.rev.dnainternet.fi [IPv6:2001:14ba:70f3:e800::a06]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 2A7DF56D for ; Tue, 12 May 2026 16:18:34 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1778595514; bh=0C7NkGZXHeneZuf+01W6/3zH1d/tX4LVvPDffTiLd1s=; h=From:To:Subject:Date:From; b=VlIhGuBE4wKlngKAfO08fMqfIEs2Mj+zsUZELcKXY+l4ysC9Fe+5BSkLlW1EoZiV6 Z7r+4d+51BXxCwotCJLx7KNf0MOT9rERDV3psbr7rhcbObGltAlUQrhsZVH6CcjMiJ rZlis5MattDSUzlvHHSc/qjb9gIp7Ph91UfpNwHU= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Subject: [PATCH] apps: common: options: Use character literal instead of string Date: Tue, 12 May 2026 17:18:40 +0300 Message-ID: <20260512141840.166903-1-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.53.0 MIME-Version: 1.0 X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" gcc 12 generates a `-Wrestrict` warning at -O3 optimization levels in C++20: g++-12 -Isrc/apps/common/libapps.a.p -Isrc/apps/common -I../src/apps/common -Iinclude -I../include -Iinclude/libcamera -fdiagnostics-color=always -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -Wextra -Werror -std=c++20 -O3 -Wnon-virtual-dtor -Wno-redundant-move -Wmissing-declarations -Wshadow -include /builds/pinchartl/libcamera/build/config.h -fPIC -DHAVE_TIFF -MD -MQ src/apps/common/libapps.a.p/options.cpp.o -MF src/apps/common/libapps.a.p/options.cpp.o.d -o src/apps/common/libapps.a.p/options.cpp.o -c ../src/apps/common/options.cpp In file included from /usr/include/c++/12/string:40, from /usr/include/c++/12/bits/locale_classes.h:40, from /usr/include/c++/12/bits/ios_base.h:41, from /usr/include/c++/12/iomanip:40, from ../src/apps/common/options.cpp:10: In static member function ‘static constexpr std::char_traits::char_type* std::char_traits::copy(char_type*, const char_type*, std::size_t)’, inlined from ‘static constexpr void std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::_S_copy(_CharT*, const _CharT*, size_type) [with _CharT = char; _Traits = std::char_traits; _Alloc = std::allocator]’ at /usr/include/c++/12/bits/basic_string.h:423:21, inlined from ‘constexpr std::__cxx11::basic_string<_CharT, _Traits, _Allocator>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::_M_replace(size_type, size_type, const _CharT*, size_type) [with _CharT = char; _Traits = std::char_traits; _Alloc = std::allocator]’ at /usr/include/c++/12/bits/basic_string.tcc:532:22, inlined from ‘constexpr std::__cxx11::basic_string<_CharT, _Traits, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::replace(size_type, size_type, const _CharT*, size_type) [with _CharT = char; _Traits = std::char_traits; _Alloc = std::allocator]’ at /usr/include/c++/12/bits/basic_string.h:2171:19, inlined from ‘constexpr std::__cxx11::basic_string<_CharT, _Traits, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::insert(size_type, const _CharT*) [with _CharT = char; _Traits = std::char_traits; _Alloc = std::allocator]’ at /usr/include/c++/12/bits/basic_string.h:1928:22, inlined from ‘constexpr std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(const _CharT*, __cxx11::basic_string<_CharT, _Traits, _Allocator>&&) [with _CharT = char; _Traits = char_traits; _Alloc = allocator]’ at /usr/include/c++/12/bits/basic_string.h:3541:36, inlined from ‘std::string Option::optionName() const’ at ../src/apps/common/options.cpp:149:34: /usr/include/c++/12/bits/char_traits.h:431:56: error: ‘void* __builtin_memcpy(void*, const void*, long unsigned int)’ accessing 9223372036854775810 or more bytes at offsets [18, 9223372036854775807] and 17 may overlap up to 9223372036854775813 bytes at offset -3 [-Werror=restrict] 431 | return static_cast(__builtin_memcpy(__s1, __s2, __n)); | ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~ Work around the issue by using a character literal instead of a string literal for single character strings. Signed-off-by: Laurent Pinchart Reviewed-by: Barnabás Pőcze --- src/apps/common/options.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) base-commit: b0dbd5100b1b1665dd2bc839d06263d55a89a6bd diff --git a/src/apps/common/options.cpp b/src/apps/common/options.cpp index b95f95afadf3..be0c161165ea 100644 --- a/src/apps/common/options.cpp +++ b/src/apps/common/options.cpp @@ -146,7 +146,7 @@ std::string Option::optionName() const if (name) return "--" + std::string(name); else - return "-" + std::string(1, opt); + return '-' + std::string(1, opt); } /* -----------------------------------------------------------------------------