From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm1-x32d.google.com (mail-wm1-x32d.google.com [IPv6:2a00:1450:4864:20::32d]) by sourceware.org (Postfix) with ESMTPS id 01D40385E009; Thu, 18 Jan 2024 11:02:55 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 01D40385E009 Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=googlemail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=googlemail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 01D40385E009 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::32d ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1705575786; cv=none; b=dkRBRiMS7eNqf9iUbkfJcHma/c/DklSs8ryZnm/XNvHW5YYisryfGB8JfCLupINQ/BrVDTRvzG+nPOskhogzfruCH8OJDHZB5tleCqPlowshxQ0wRCb0ZmpnE6lruYvib5zstitc3Ee/Mv7h8CpIImi+JtJu3wMeMEwSMejoEso= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1705575786; c=relaxed/simple; bh=lHu6yPRJAuQqHDtx2XkXo0YJUdWtKx9kXiQ/Pj4vdqU=; h=DKIM-Signature:Mime-Version:Subject:From:Date:Message-Id:To; b=nLk1G9U52ObZGsB4J0hN0Bo3n4Bvn8ahiVPKofCyDmdwcx894TOCqF2Qe3mNOokL7kHmmeLPAiAn9G5Uvt8yiUktd5aVIvDDjyzIwoEE9f8mdO4rx0GwKDDOVpDscpenXJRDuIj39gvcp21b7y9trt+JFrjGEnBayq8kNzscWvo= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-wm1-x32d.google.com with SMTP id 5b1f17b1804b1-40e76626170so44504595e9.2; Thu, 18 Jan 2024 03:02:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20230601; t=1705575775; x=1706180575; darn=gcc.gnu.org; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=WeK/WMugQ9CUhv7kXAALoGqiGmp24/fWpqksF+NuLjo=; b=WJ+AOFQVjY5TLfP/k/xXHRPttMTgXM0HZYhhlIcjYGYPKIH+Ym6fUHT87uAC2bzTR6 qriYNjO7UTsoX3oqFKsowPnFUUXjJRYJ8LYxXL/PeYvfPulqd2hoWv1/4h9JBJ1AMqi8 tEXSnJSrgb7Jx5T0JTg7uVI3xdFQ13lJuB1QJw0W8LmNgBbpw21q18he1T3h39i7+gLL QBG0rD/3QT0+3H3dq5FOjmDIjkDoaLMk1zR+ExG8UytvpxJNeESxhtr+FKN3xLdsyz0i ic7lfK3jeBAUcgRPfBlFb9y4ftEu06AxS4jyViJ0fcpUfCPwqs6SZ6T4ltZtAUwn6/HN SxcA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705575775; x=1706180575; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=WeK/WMugQ9CUhv7kXAALoGqiGmp24/fWpqksF+NuLjo=; b=VK2ohuVU5RgOaMhYSSP/3okPkkUYjJcEsx4nMCrTllNwv9Xj1PaVEpdUD8DWkiat9Q kVYuK0CVtnGhUpV3Jcsx9jKvKSVWfTED0axOJy2edCjPtL5XVyIddpWJ5U5MPM4JUSrG qRaHudKrBwvdyNdlKQNLRkrDgMqeSU/Fau+vY6WDKvB1lq10jxR/OYfu3Kz3nAZ0XylO +4+/BK9GE9OOUrhg4OiVd+NURxqsuSBaBfoZrIb9b2EMKeD/skcYvle5p50DQsuoRQJs dkYnbrCrldj4we6ejFML41XHl2cCRP014OBzXRxXVmRk5Jiq1RU5uiAPDlfrJ5Q8LwUD PjFg== X-Gm-Message-State: AOJu0Yyj2xNfXv6DgYmBqQVMOTVG8PuznRXKoY/1w0davEkMHwYnQ9mu bnWxZ6+Kaw/rtlXFaXED3xTnVLLvPugsPs/kPfaew3jTWmLI1dAYq577g8Ld X-Google-Smtp-Source: AGHT+IHugFdiXS4pQGMetPfn1u/0oRswWerKsQzirK1H5jTwwFxbOoOJt0wK5MaGDx755sh8nEmmxw== X-Received: by 2002:a05:600c:13c3:b0:40e:6ca1:b0d0 with SMTP id e3-20020a05600c13c300b0040e6ca1b0d0mr449670wmg.53.1705575774443; Thu, 18 Jan 2024 03:02:54 -0800 (PST) Received: from smtpclient.apple (host81-138-1-83.in-addr.btopenworld.com. [81.138.1.83]) by smtp.googlemail.com with ESMTPSA id m26-20020a05600c3b1a00b0040e4c1dade4sm29604649wms.36.2024.01.18.03.02.53 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 18 Jan 2024 03:02:54 -0800 (PST) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3696.120.41.1.4\)) Subject: Re: [COMMITTED] rust_debug: Cast size_t values to unsigned long before printing. From: Iain Sandoe In-Reply-To: <7b53ee9e-1830-4878-9e12-b3e748a2e4fd@embecosm.com> Date: Thu, 18 Jan 2024 11:02:53 +0000 Cc: GCC Patches , gcc-rust@gcc.gnu.org Content-Transfer-Encoding: quoted-printable Message-Id: <282A2062-61F0-46B5-96C3-23FBBE5D3130@googlemail.com> References: <20240118090056.2910410-2-arthur.cohen@embecosm.com> <7b53ee9e-1830-4878-9e12-b3e748a2e4fd@embecosm.com> To: Arthur Cohen X-Mailer: Apple Mail (2.3696.120.41.1.4) X-Spam-Status: No, score=-8.7 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Hi Arthur, > On 18 Jan 2024, at 10:30, Arthur Cohen = wrote: > On 1/18/24 10:13, Rainer Orth wrote: >> Arthur Cohen writes: >>> Using %lu to format size_t values breaks 32 bit targets, and %zu is = not >>> supported by one of the hosts GCC aims to support - HPUX >> But we do have uses of %zu in gcc/rust already! >>> diff --git a/gcc/rust/expand/rust-proc-macro.cc = b/gcc/rust/expand/rust-proc-macro.cc >>> index e8618485b71..09680733e98 100644 >>> --- a/gcc/rust/expand/rust-proc-macro.cc >>> +++ b/gcc/rust/expand/rust-proc-macro.cc >>> @@ -171,7 +171,7 @@ load_macros (std::string path) >>> if (array =3D=3D nullptr) >>> return {}; >>> - rust_debug ("Found %lu procedural macros", array->length); >>> + rust_debug ("Found %lu procedural macros", (unsigned long) = array->length); >> Not the best way either: array->length is std::uint64_t, so the = format >> should use >> ... %" PRIu64 " procedural... >> instead. >> I've attached my patch to PR rust/113461. >=20 > Yes, I was talking about this on IRC the other day - if we do run in a = situation where we have more than UINT32_MAX procedural macros in memory = we have big issues. These debug prints will probably end up getting = removed soon as they clutter the output a lot for little information. >=20 > I don't mind doing it the right way for our regular prints, but we = have not been using PRIu64 in our codebase so far, so I'd rather change = all those incriminating format specifiers at once later down the line - = this patch was pushed so that 32bit targets could bootstrap the Rust = frontend for now. For the sake of completeness, the issue does not just affect 32b hosts; = If a 64b host chooses (as Darwin does, so that 32b and 64b targets have = the same representation) to make uint64_t =E2=80=9Cunsigned long long = int=E2=80=9D, then %lu breaks there too. thanks Iain