Skip to content
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

2025/01/28 Warnings Hackathon #20198

Open
cyrush opened this issue Jan 23, 2025 · 8 comments
Open

2025/01/28 Warnings Hackathon #20198

cyrush opened this issue Jan 23, 2025 · 8 comments

Comments

@cyrush
Copy link
Member

cyrush commented Jan 23, 2025

Directory Partitioning:

Justin:

Mark:

Kathleen:

Cyrus:

  • AVT generally, State Objects?
@cyrush
Copy link
Member Author

cyrush commented Jan 28, 2025

Link to discussion w/ warnings flags:
#19003

@cyrush
Copy link
Member Author

cyrush commented Jan 28, 2025

Warnings Encountered:

  • -Winconsistent-missing-override
  • -Wdeprecated-declarations (sprintf)
  • -Wold-style-cast

@cyrush
Copy link
Member Author

cyrush commented Jan 28, 2025

options not understood by clang:

warning: unknown warning option '-Wduplicated-cond' [-Wunknown-warning-option]
warning: unknown warning option '-Wduplicated-branches' [-Wunknown-warning-option]
warning: unknown warning option '-Wlogical-op'; did you mean '-Wlong-long'? [-Wunknown-warning-option]
warning: unknown warning option '-Wuseless-cast' [-Wunknown-warning-option]

@biagas
Copy link
Contributor

biagas commented Jan 29, 2025

Are we fixing warnings like this where we are accessing elements of a std::vector with an int ?
I have found it isn't always feasible to change the type of the index being used.

warning: conversion to ‘std::vector<double>::size_type’ {aka ‘long unsigned int’} from ‘int’ may change the sign of the result [-Wsign-conversion]
  567 |         else if (val < enumerationRanges[2*mid])
      |                                          ~^~~~

@JustinPrivitera
Copy link
Member

Why not static_cast it?

@biagas
Copy link
Contributor

biagas commented Jan 30, 2025

@JustinPrivitera Like this?
else if (val < enumerationRanges[static_cast<size_t>(2*mid)])

Doable, sure, but it gets very verbose and hard to read when the item being cast gets complicated (I have a number of them doing much arithmetic in between the [ ]). I guess I could use temporary variables to hold the arithmetic results.

@JustinPrivitera
Copy link
Member

Yes that's what I was suggesting.

If there is any math being done within the [ ] that is done in multiple places than that is a good argument for pulling the calculations out into a new variable. I think it is also usually cleaner to define a new variable for indexing calculations.

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

No branches or pull requests

3 participants