Skip to content

Fix narrowing conversion warnings #3732

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 28, 2025
Merged

Conversation

powerboat9
Copy link
Collaborator

@powerboat9
Copy link
Collaborator Author

Open to suggestions on how to make this a bit less ugly, but we should probably fix this bug before GCC 15 releases

Copy link
Member

@CohenArthur CohenArthur left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this is the best way to go about this. In some places the ID stored was size - 1, which is different here. I think we can also find a cleaner way to do this, like maybe storing size_t instead of uint32_t in all of those *Id structs? It used to be an issue when they were type aliases but that's no longer the case

@powerboat9
Copy link
Collaborator Author

The emplace_back calls increment the value returned by size. As for changing the value type to size_t, that does sound ideal, but I don't know why we're using uint32_t in the first place, some data structure size optimization?

@powerboat9
Copy link
Collaborator Author

@jdupak

@powerboat9
Copy link
Collaborator Author

I don't think this is the best way to go about this. In some places the ID stored was size - 1, which is different here. I think we can also find a cleaner way to do this, like maybe storing size_t instead of uint32_t in all of those *Id structs? It used to be an issue when they were type aliases but that's no longer the case

What was an issue with type aliases? Some 32-bit compatibility issue, where uint32_t may or may not have been equivalent to size_t? I think I remember something like that

Fixes PR#119641

gcc/rust/ChangeLog:

	* checks/errors/borrowck/rust-bir-place.h
	(IndexVec::size_type): Add.
	(IndexVec::MAX_INDEX): Add.
	(IndexVec::size): Change the return type to the type of the
	internal value used by the index type.
	(PlaceDB::lookup_or_add_variable): Use the return value from the
	PlaceDB::add_place call.
	* checks/errors/borrowck/rust-bir.h
	(struct BasicBlockId): Move this definition before the
	definition of the struct Function.

Signed-off-by: Owen Avery <[email protected]>
@powerboat9
Copy link
Collaborator Author

I think I've found a better way to do this, by modifying IndexVec

@powerboat9 powerboat9 requested a review from CohenArthur April 17, 2025 04:36
Copy link
Member

@CohenArthur CohenArthur left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ooooh I really like that, well done!! I think this would be really good

@CohenArthur CohenArthur added this pull request to the merge queue Apr 28, 2025
Merged via the queue into Rust-GCC:master with commit 161e3c6 Apr 28, 2025
12 checks passed
@powerboat9 powerboat9 deleted the fix-warn branch April 28, 2025 21:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants