From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id GeMSAdSusWlOAyQAWB0awg (envelope-from ) for ; Wed, 11 Mar 2026 14:05:08 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=simark.ca; s=mail; t=1773252307; bh=P8MGbWnmNxifdneTBPNn0hwjOgujOZrWIzhWb1ms1+Q=; h=Date:Subject:To:Cc:References:From:In-Reply-To:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=ZvW3z08z09K4uY5XDF9nou17ih5CjG3lN50p5yzKeRRoZf3Itibnbf8hV8YlIUSPq GjVhyxCdFi+vuWXVgc+6LoIKZT1nzMBX7PvSiRPGOS2iv3/462lidlktJqNTjaq8E0 D4SlFivddWjCwpTbiiEj+KxuOmMyeYvtmwwWPVWw= Received: by simark.ca (Postfix, from userid 112) id E8B351E089; Wed, 11 Mar 2026 14:05:07 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-2.4 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,RCVD_IN_MSPIKE_H2,RCVD_IN_VALIDITY_CERTIFIED_BLOCKED, RCVD_IN_VALIDITY_RPBL_BLOCKED,RCVD_IN_VALIDITY_SAFE_BLOCKED autolearn=ham autolearn_force=no version=4.0.1 Authentication-Results: simark.ca; dkim=pass (1024-bit key; unprotected) header.d=simark.ca header.i=@simark.ca header.a=rsa-sha256 header.s=mail header.b=Vk8mjrg3; dkim-atps=neutral Received: from vm01.sourceware.org (vm01.sourceware.org [38.145.34.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 2F94B1E089 for ; Wed, 11 Mar 2026 14:05:07 -0400 (EDT) Received: from vm01.sourceware.org (localhost [127.0.0.1]) by sourceware.org (Postfix) with ESMTP id 29D7E4BB58AE for ; Wed, 11 Mar 2026 18:05:06 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 29D7E4BB58AE Authentication-Results: sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=simark.ca header.i=@simark.ca header.a=rsa-sha256 header.s=mail header.b=Vk8mjrg3 Received: from simark.ca (simark.ca [158.69.221.121]) by sourceware.org (Postfix) with ESMTPS id A9A304BB3BF5 for ; Wed, 11 Mar 2026 18:04:36 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org A9A304BB3BF5 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=simark.ca Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=simark.ca ARC-Filter: OpenARC Filter v1.0.0 sourceware.org A9A304BB3BF5 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=158.69.221.121 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1773252276; cv=none; b=WVHLbo/7orEnrNiHqmRmXKHE7jK1RnwlqkinuJaeYBo9G98bBnW6i5nxI4djFd8BkOcQQUYh6/UkWrZI8WHFCEwWwrM9yVtWE7zINWjuay72MLY+ExDs2WnbwZoObAkFGovekiNAV9aa/1vaO+SXoPWphxrXzqqQCl1eFgli51Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1773252276; c=relaxed/simple; bh=P8MGbWnmNxifdneTBPNn0hwjOgujOZrWIzhWb1ms1+Q=; h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:To:From; b=GAQo6eZVofGAQLyczXwxsjt05Yi/bfb1mwbjmXFVAhVwll65tIiVtUmjRF++idbfNpXCHV9nGRactViUE3CAPSw3Kbykf+fo+4p53rv4ma9JFebdITvxi1bRl2esOCEATmbht4VTKu9Iri/lv/SO6Bwl+ggzzT8tHk1egWL7Uxc= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A9A304BB3BF5 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=simark.ca; s=mail; t=1773252274; bh=P8MGbWnmNxifdneTBPNn0hwjOgujOZrWIzhWb1ms1+Q=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=Vk8mjrg338C4D4NEOWaW7bQQwaLS6TZW9gzA2yNWz53BihTmI2Q9BdBbTyuUVWEs5 ZrSH6nF/m1Q3B/AkbluXEHVTQaqmqEGmeJgjv892d+a7BWPVwhl8yQ86fKl/DUIcti 8SI/m5J0nCWU+zf3aK6K4lNtodN1BYO961PBen/E= Received: by simark.ca (Postfix) id 87CB61E089; Wed, 11 Mar 2026 14:04:34 -0400 (EDT) Message-ID: Date: Wed, 11 Mar 2026 14:04:34 -0400 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v3 1/7] gdb: introduce rgb_color type to simplify existing code To: Matthieu Longo , Tom Tromey Cc: gdb-patches@sourceware.org References: <20260309175624.236491-1-matthieu.longo@arm.com> <20260309175624.236491-2-matthieu.longo@arm.com> <87eclsx0xn.fsf@tromey.com> <0762aa68-ad5c-4edc-b1ad-72109e613301@simark.ca> <6709ef98-2ff2-47d7-b292-9c6b02f5fc05@arm.com> Content-Language: fr From: Simon Marchi In-Reply-To: <6709ef98-2ff2-47d7-b292-9c6b02f5fc05@arm.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces~public-inbox=simark.ca@sourceware.org On 3/11/26 1:55 PM, Matthieu Longo wrote: > On 11/03/2026 15:03, Simon Marchi wrote: >> On 3/9/26 3:22 PM, Tom Tromey wrote: >>>>>>>> Matthieu Longo writes: >>> >>>> This patch replaces the raw uint8[3] buffer used to represent RGB values >>>> with a more convenient wrapper, rgb_color, around std::array. >>>> It also changes the return type of ui_file_style::color::get_rgb to >>>> rgb_color instead of filling a caller-provided buffer, and updates all >>>> callers accordingly. >>> >>> One tiny nit. >>> >>>> if (target_space == color_space::RGB_24BIT) >>>> { >>>> - uint8_t rgb[3]; >>>> - get_rgb (rgb); >>>> - return color (rgb[0], rgb[1], rgb[2]); >>>> + return color (get_rgb ()); >>>> } >>> Since there's only one statement now, the braces should be removed. >>> >>> This is ok with this change. >>> Approved-By: Tom Tromey >>> >>> Tom >> >> This appears to have caused a build failure on armhf: >> >> https://builder.sourceware.org/buildbot/#/builders/72/builds/7402/steps/4/logs/stdio >> >> Sample: >> >> ../../binutils-gdb/gdb/tui/tui-io.c: In function ‘bool get_color(const ui_file_style::color&, int*)’: >> ../../binutils-gdb/gdb/tui/tui-io.c:260:38: error: ISO C++ says that these are ambiguous, even though the worst conversion for the first is better than the worst conversion for the second: [-Werror] >> 260 | if (init_color (next, rgb[0] * 1000 / 255, rgb[1] * 1000 / 255, >> | ^ >> In file included from ./../../binutils-gdb/gdb/ui-file.h:23, >> from ./../../binutils-gdb/gdb/defs.h:60, >> from : >> ./../../binutils-gdb/gdb/ui-style.h:78:22: note: candidate 1: ‘constexpr uint8_t& rgb_color::operator[](std::size_t)’ >> 78 | constexpr uint8_t &operator[] (std::size_t idx) noexcept >> | ^~~~~~~~ >> ../../binutils-gdb/gdb/tui/tui-io.c:260:38: note: candidate 2: ‘operator[](uint8_t* {aka unsigned char*}, int)’ (built-in) >> 260 | if (init_color (next, rgb[0] * 1000 / 255, rgb[1] * 1000 / 255, >> | ^ >> >> It seems to be because an rgb_color can be implicitly converted to a >> `uint8_t *`, which can be subscripted, but also has an operator[]. >> >> Not sure why the uint8_t* operator is needed, > > It was originally required for this line when passing rgb to memcpy(). > > memcpy (rgb, palette_8colors[m_value], rgb.bytes_size ()); > > But was later replaced by this assignment: > > rgb = palette_8colors[m_value]; > >> but it compiles fine here if I remove it. If really needed, I think that an explicit method >> (`.data()`) would be preferable, to avoid unwanted conversions. >> >> Simon > > I locally tested the removal of this uint8_t* operator, and the code compiles fine. > > diff --git a/gdb/ui-style.h b/gdb/ui-style.h > index a1d656cd39c..fc40b93709d 100644 > --- a/gdb/ui-style.h > +++ b/gdb/ui-style.h > @@ -72,7 +72,6 @@ struct rgb_color > constexpr uint8_t g () const noexcept { return m_data[1]; } > constexpr uint8_t b () const noexcept { return m_data[2]; } > > - constexpr operator uint8_t *() noexcept { return m_data.data (); } > constexpr size_t size () const noexcept { return m_data.size (); } > > constexpr uint8_t &operator[] (std::size_t idx) noexcept > > Do you want me to publish a patch for this ? Or will you fix it ? Please push a patch that does exactly that. You can put my: Approved-By: Simon Marchi Simon