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 — added `constness_ptr` as pointer wrapper to ensure actual method constness by firewave · Pull Request #4785 · cppcheck-opensource/cppcheck

Conversation

@firewave

@firewave firewave commented Feb 10, 2023

Copy link
Copy Markdown
Collaborator

No description provided.

Sorry, something went wrong.

Uh oh!

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

All reactions
@firewave

This comment was marked as outdated.

Sign in to view
@firewave
firewave force-pushed the safe_ptr branch from 8eb0c20 to c8a23dc Compare February 10, 2023 12:35
@firewave

This comment was marked as outdated.

Sign in to view
@firewave firewave mentioned this pull request Feb 17, 2023
reduced usage of mutable Settings objects in tests #4798
Merged
@firewave

This comment was marked as outdated.

Sign in to view
@firewave firewave mentioned this pull request Mar 9, 2023
pass TokenList as reference into ValueFlow::setValues() #4868
Merged
@firewave

This comment was marked as outdated.

Sign in to view
@firewave firewave mentioned this pull request Aug 25, 2023
[clang-tidy] False positive readability-make-member-function-const when const overload already exists llvm/llvm-project#64988
Open
@firewave

firewave commented Aug 25, 2023

Copy link
Copy Markdown
Collaborator Author

There's std::experimental::propagate_const as pointed out here: llvm/llvm-project#64988 (comment). Looks quite familiar.

All reactions

Sorry, something went wrong.

Uh oh!

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

@firewave
firewave force-pushed the safe_ptr branch from c8a23dc to 4ca95cc Compare August 29, 2023 09:31
@firewave firewave mentioned this pull request Mar 11, 2024
ValueFlow: pass ErrorLogger by reference into ValueFlow::setValues() / removed need for LifetimeStore::Context #5299
Merged
@firewave

firewave commented Nov 12, 2024

Copy link
Copy Markdown
Collaborator Author

We do not have many pointer left in the code so this should be taking a reference now.

All reactions

Sorry, something went wrong.

Uh oh!

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

@firewave
firewave force-pushed the safe_ptr branch from 4ca95cc to d18f173 Compare November 12, 2024 19:36
@firewave
firewave force-pushed the safe_ptr branch 2 times, most recently from 35a740b to d193431 Compare April 14, 2025 10:15
@firewave
firewave marked this pull request as ready for review April 14, 2025 10:24
@firewave

firewave commented Apr 14, 2025

Copy link
Copy Markdown
Collaborator Author

We do not have many pointer left in the code so this should be taking a reference now.

I will tackle references later on - let's start with the pointers which are not supposed to be references yet.

All reactions

Sorry, something went wrong.

Uh oh!

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

@firewave
firewave force-pushed the safe_ptr branch from d193431 to 897c546 Compare April 14, 2025 19:27
@danmar

danmar commented Apr 15, 2025

Copy link
Copy Markdown
Collaborator

I don't really understand what we achieve with this safe_ptr class. Does it prevent some lifetime issue?

All reactions

Sorry, something went wrong.

Uh oh!

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

@firewave

firewave commented Apr 15, 2025 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown
Collaborator Author

From https://en.cppreference.com/w/cpp/experimental/propagate_const:

It treats the wrapped pointer as a pointer to const when accessed through a const access path, hence the name. 
All reactions

Sorry, something went wrong.

Uh oh!

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

@firewave

firewave commented Apr 15, 2025

Copy link
Copy Markdown
Collaborator Author

The name is misleading though. I think this started as something totally different. Not sure what to call it - constness_ptr, propagate_const_ptr, ptr_wrapper, ...?

All reactions

Sorry, something went wrong.

Uh oh!

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

@danmar

danmar commented Apr 17, 2025 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown
Collaborator

I feel a bit skeptic about this spontanously. But yeah some name that indicates that const is propagated sounds good. But at the same time it shouldn't be too long.

I wonder how people would feel about a cppcheck checker that tells them about accessing non-const member data using const pointers. Spontanously it seems wrong to do that and I could use that in our selfchecks at least. or do you know a use case when we would want to write such data?

I considered such a checker a long time ago but I dropped the idea for some reason. I don't remember why. But I guess it was simply because of limited time and there are plenty of undefined behavior to discover so I rather wanted to work on that.

All reactions

Sorry, something went wrong.

Uh oh!

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

@firewave

firewave commented Apr 17, 2025

Copy link
Copy Markdown
Collaborator Author

I wonder how people would feel about a cppcheck checker that tells them about accessing non-const member data using const pointers. Spontanously it seems wrong to do that and I could use that in our selfchecks at least. or do you know a use case when we would want to write such data?

https://trac.cppcheck.net/ticket/11127

Not really a use case but something which will cause a lot of const to be dropped if this is fully applied (I think that might include references - not sure about this, it has been too long) is the ErrorLogger usage.

On a side note I wonder if there is a simple trick to propagate that a function should not be const. Like adding (void)this; to avoid a function to be static.

All reactions

Sorry, something went wrong.

Uh oh!

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

@firewave
firewave marked this pull request as draft April 17, 2025 07:10
@firewave
firewave force-pushed the safe_ptr branch from 897c546 to 922dcdc Compare April 22, 2025 07:11
@firewave

firewave commented Apr 22, 2025

Copy link
Copy Markdown
Collaborator Author

I renamed it constness_ptr. Feels awkward but basically describes what it does.

All reactions

Sorry, something went wrong.

Uh oh!

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

@firewave firewave changed the title added safe_ptr as pointer wrapper to ensure actual method constness added constness_ptr as pointer wrapper to ensure actual method constness Apr 22, 2025
@firewave
firewave marked this pull request as ready for review April 22, 2025 07:12
@danmar

danmar commented May 6, 2025

Copy link
Copy Markdown
Collaborator

I renamed it constness_ptr. Feels awkward but basically describes what it does.

I like that name better.

All reactions

Sorry, something went wrong.

Uh oh!

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

@firewave
firewave marked this pull request as draft May 6, 2025 09:09
@firewave
added constness_ptr as pointer wrapper to ensure actual method cons…
b943650
…tness [skip ci]
@firewave
firewave force-pushed the safe_ptr branch from 922dcdc to b943650 Compare May 6, 2025 09:09
@firewave firewave mentioned this pull request Sep 8, 2025
Fix #14119 FN constVariablePointer for variable declared in for loop / partial fix for #14148 #7807
Merged
This was referenced Sep 24, 2025
clang-tidy.yml: updated to Clang 21 cppcheck-opensource/simplecpp#421
Merged
added constness_ptr as pointer wrapper to ensure actual method constness cppcheck-opensource/simplecpp#548
Draft
@firewave

firewave commented Sep 24, 2025

Copy link
Copy Markdown
Collaborator Author

I implemented it in simplecpp - see cppcheck-opensource/simplecpp#548.

All reactions

Sorry, something went wrong.

Uh oh!

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

@firewave firewave mentioned this pull request Jul 8, 2026
Fix 15102: Make copy-constructible classes copyable #8705
Merged
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

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.

2 participants

@firewave @danmar
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 01402503 — 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.