On Wed, Jun 25 2025, Martin Jambor wrote:
> Hi,
>
> when compiling
> gcc/rust/checks/errors/borrowck/rust-borrow-checker-diagnostics.cc
> with clang, it emits the following warning:
>
>   gcc/rust/checks/errors/borrowck/rust-borrow-checker-diagnostics.cc:145:46: 
> warning: non-constant-expression cannot be narrowed from type 
> 'Polonius::Loan' (aka 'unsigned long') to 'uint32_t' (aka 'unsigned int') in 
> initializer list [-Wc++11-narrowing]
>
> I'd hope that for indexing that is never really a problem,
> nevertheless if narrowing is taking place, I guess it can be argued it
> should be made explicit.
>
> I have so far only tested this with the clang compile, I will try to
> do a bootstrap with rust-enabled too.
>
> Philip, Pierre, would you be willing to incorporate this into your
> tree and commit it to master at gcc.gnu.org from there?  Or should I
> commit it to master at gcc.gnu.org and you'll merge it from there?

This has been approved on Zulip and so I have pushed this as
1e69c565589.

Thanks,

Martin


>
> Thanks,
>
> Martin
>
>
> gcc/rust/ChangeLog:
>
> 2025-06-23  Martin Jambor  <mjam...@suse.cz>
>
>       * checks/errors/borrowck/rust-borrow-checker-diagnostics.cc
>       (BorrowCheckerDiagnostics::get_loan): Type cast loan to uint32_t.
> ---
>  .../checks/errors/borrowck/rust-borrow-checker-diagnostics.cc   | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git 
> a/gcc/rust/checks/errors/borrowck/rust-borrow-checker-diagnostics.cc 
> b/gcc/rust/checks/errors/borrowck/rust-borrow-checker-diagnostics.cc
> index 6c67706780b..adf1448791e 100644
> --- a/gcc/rust/checks/errors/borrowck/rust-borrow-checker-diagnostics.cc
> +++ b/gcc/rust/checks/errors/borrowck/rust-borrow-checker-diagnostics.cc
> @@ -142,7 +142,7 @@ BorrowCheckerDiagnostics::get_statement (Polonius::Point 
> point)
>  const BIR::Loan &
>  BorrowCheckerDiagnostics::get_loan (Polonius::Loan loan)
>  {
> -  return bir_function.place_db.get_loans ()[{loan}];
> +  return bir_function.place_db.get_loans ()[{(uint32_t) loan}];
>  }
>  
>  const HIR::LifetimeParam *
> -- 
> 2.49.0

Reply via email to