From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm1-x32f.google.com (mail-wm1-x32f.google.com [IPv6:2a00:1450:4864:20::32f]) by sourceware.org (Postfix) with ESMTPS id E4CE23858D33 for ; Thu, 18 Jan 2024 20:21:12 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org E4CE23858D33 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=embecosm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=embecosm.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org E4CE23858D33 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::32f ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1705609274; cv=none; b=TzKmckERommYlQUzNTS1ujrtFu9rXp9IubHkQW+KMhqVuQsJ3gwGOLILG8m391rlctv1woNTfXiaqswb2MsICpL/xgofI8FDmnTuiMZ6/vMMrdQuKXe/XeG+abCihRuE457a3HdJ02/Qy/8YzSk6tiGm6x1y1s786kqLGAnoKw4= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1705609274; c=relaxed/simple; bh=FxX1b/RF3alVUI/+VNJZBl93qU+2TSyrFWe65IprGvM=; h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:To:From; b=HWiSKbqcOAukeJnsQ/2lytAtut1edanqyEnesl+4jgxS4L/5/wO89hhAcbmsRGHm9W0VmpwTja4U7E+FLuopLcAHFUUA34D2Z7I3Cu0aouK2dAIvGvFOyQYjt9bCb8wAEnB8Z3QOgKmjsrtQ9b4mphMka9+a8lhXaAT4TJl7M/w= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-wm1-x32f.google.com with SMTP id 5b1f17b1804b1-40e779f0273so395565e9.2 for ; Thu, 18 Jan 2024 12:21:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=embecosm.com; s=google; t=1705609271; x=1706214071; darn=gcc.gnu.org; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=Pr262ZpffAZV/hFGQTNF//IbluYHwL1f2Lr7K35JuR4=; b=aJUhPKgVQ7+nSqi7cVUSZYPHoLfmh4gufxNitxvHp/EkuvvKnZJ4dtbq7it5xqUiHn NfhpBrECR2im4GKEKMRGn9mk3+lPjoG6twwkr3Z38qrvUTXamovHXgPJqoT/BFpsBvUu K+5/pWUUkec6ZMbHUtyOCSo0yxVnkKhJeIZkFar5IieCtikGeVarWJFjyYc2MiUx2+JM pooGBfB5HEaNLNtyL7pFjjVyxDPnTbTwVIrSr1a5sWT8PiNq2CtuIjGKtZGEsaTeunz6 QLBMGAQiEea0CwZL/kUxCugtePgkIty+mczlZzP3Lxm7NP/mVMgAHHP1BYAbT1sgR1Fh Z0rg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705609271; x=1706214071; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=Pr262ZpffAZV/hFGQTNF//IbluYHwL1f2Lr7K35JuR4=; b=YohQ7v+E89vexnUQxPnuwr4TxjkXOyYayyU2nBfLaKWkekHxVoL5CKyEVtP0zMPEsP dsyyILKkVhew61zHC+QeszLliKtQ0eJJmZqmYQJUbV5G0/dug9YfZ0vUkxOu0/Rmoryj +h/y23W2j1LJOpfsoHPBG2laQGvopSuuwybT7dhOYt26hWiWf7wKKQ0sqZMulXY7YddU AC15d1dvY4ITnll40bhromPWTyge1rgsAAH7sE3g/QfmRIs0L/oLZrfn+2IgtNd6E+EZ iQ4p9F7SsVTFC1O1aRpRontRlj9JZULqlQzXD8ycHb6SlpT0oe/W7cPXwswi6u+vXHcG jixw== X-Gm-Message-State: AOJu0Yx021CJSE1lV6E8EsHnsdQ6RZ3fr5ycsHC9GIXhofVtjb/QHJMR dl2XCZtVDDvNdm6Lj1eV6SP72aGaZfmOo63dzN/ssNC3Uc+d0eSOTrm+Y33DqQ== X-Google-Smtp-Source: AGHT+IFsM6oQSMDn0z+5TSWpxYnf5Se7j7ZgV/wwqCqumiUgNZmhoCZZeUEzXBsErYqMHP3UPtsrww== X-Received: by 2002:a7b:cb04:0:b0:40e:5534:728c with SMTP id u4-20020a7bcb04000000b0040e5534728cmr806045wmj.136.1705609270959; Thu, 18 Jan 2024 12:21:10 -0800 (PST) Received: from ?IPV6:2a04:cec2:28:c7b4:d00c:36ef:969e:37f6? ([2a04:cec2:28:c7b4:d00c:36ef:969e:37f6]) by smtp.gmail.com with ESMTPSA id es18-20020a056402381200b00554b1d1a934sm9892092edb.27.2024.01.18.12.21.10 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 18 Jan 2024 12:21:10 -0800 (PST) Message-ID: <0389bc16-46f1-41e8-ab50-5ef38bb874d8@embecosm.com> Date: Thu, 18 Jan 2024 21:21:03 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [COMMITTED] rust_debug: Cast size_t values to unsigned long before printing. Content-Language: en-US To: Iain Sandoe Cc: GCC Patches , gcc-rust@gcc.gnu.org References: <20240118090056.2910410-2-arthur.cohen@embecosm.com> <7b53ee9e-1830-4878-9e12-b3e748a2e4fd@embecosm.com> <282A2062-61F0-46B5-96C3-23FBBE5D3130@googlemail.com> From: Arthur Cohen In-Reply-To: <282A2062-61F0-46B5-96C3-23FBBE5D3130@googlemail.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-13.7 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,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 Iain, On 1/18/24 12:02, Iain Sandoe wrote: > 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 == 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. >> >> 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. >> >> 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 “unsigned long long int”, then %lu breaks there too. > thanks > Iain > Thanks for the precision! I'll definitely be more careful moving forward. Kindly, Arthur