GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Brodes/nested sizeof or operation in sizeof audit fixes by bdrodes · Pull Request #310 · microsoft/codeql

Conversation

@bdrodes

@bdrodes Ben Rodes (bdrodes) commented Dec 16, 2025

Copy link
Copy Markdown

Fixes false positives as a result of a new audit.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Ben Rodes (bdrodes) added 2 commits December 16, 2025 09:39
@bdrodes
False positive fix regarding common type check idioms.
d2cefd2
@bdrodes
Simplifying sizeof query output messages, and making both consistent …
a412b91
…with each other.
@bdrodes
Ben Rodes (bdrodes) marked this pull request as ready for review December 16, 2025 18:38
LWSimpkins
Lindsay Simpkins (LWSimpkins) approved these changes Dec 16, 2025
View reviewed changes
@bdrodes
Ben Rodes (bdrodes) merged commit 286fc27 into main Dec 16, 2025
MathiasVP
Mathias Vorreiter Pedersen (MathiasVP) reviewed Dec 17, 2025
View reviewed changes
Comment thread cpp/ql/src/Microsoft/Likely Bugs/SizeOfMisuse/ArgumentIsSizeofOrOperation.ql
Comment on lines +28 to +32
// Apparently derived types, eg., functoin pointers, aren't PointerType
// according to codeql, so special casing them out here.
other.getUnspecifiedType() instanceof DerivedType
or
op instanceof SizeofOperator and tmpMsg = "sizeof"
) and
if sizeofExpr.isInMacroExpansion()
then message = tmpMsg + "(in a macro expansion)"
else message = tmpMsg
other.getUnspecifiedType() instanceof PointerType

@MathiasVP Mathias Vorreiter Pedersen (MathiasVP) Dec 17, 2025

Copy link
Copy Markdown
Collaborator

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Did you really mean for other.getUnspecifiedType() instanceof DerivedType? It's true that funmction pointers aren't PointerTypes, but then I would have assumed that you would do:

other.getUnspecifiedType() instanceof FunctionPointerType

(or maybe FunctionPointerIshType.), but you use DerivedType which includes lots of other things such as reference types, and const/volatile types (but you are calling getUnspecifiedType so const/volatiles are removed. All in all, this is very confusing 😂 Also, since PointerTypes are also DerivedTypes what you wrote is equivalent to:

other.getUnspecifiedType() instanceof DerivedType

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@bdrodes Ben Rodes (bdrodes) Dec 17, 2025

Copy link
Copy Markdown
Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

I missed they shared a common ancestor of derived. I should just make it instanceof Derived Type like you mentioned. I'll make that change. I don't mind that derived type includes other things, but I if Derived type does include specifiers for some reason... that is confusing. Basically I wanted to make the pattern as generic as possible. (TYPE*)0 == (other). I suppose I could maybe ignore "other's" type might be the most general solution.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@bdrodes Ben Rodes (bdrodes) Dec 17, 2025

Copy link
Copy Markdown
Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Diving more, yea it is confusing that derived type includes the const/volatile specifiers. That's unfortunate. I'm going to special case to just function pointer as you suggest and see if it changes my results. If not, I'll submit a new PR with this fix.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Ben Rodes (bdrodes) added a commit that referenced this pull request Feb 6, 2026
@bdrodes
Brodes/nested sizeof or operation in sizeof audit fixes (#310)
6016108
* False positive fix regarding common type check idioms.

* Simplifying sizeof query output messages, and making both consistent with each other.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@MathiasVP Mathias Vorreiter Pedersen (MathiasVP) MathiasVP left review comments
@LWSimpkins Lindsay Simpkins (LWSimpkins) LWSimpkins approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@bdrodes @MathiasVP @LWSimpkins
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.