Title: Sorted instances of Check by ghewgill · Pull Request #12 · cppcheck-opensource/cppcheck · GitHub
Open Graph Title: Sorted instances of Check by ghewgill · Pull Request #12 · cppcheck-opensource/cppcheck
X Title: Sorted instances of Check by ghewgill · Pull Request #12 · cppcheck-opensource/cppcheck
Description: I noticed that the instances().sort() in Check::Check() doesn't actually sort anything.
The first commit adds a test case to check whether the instances list really is sorted. This should fail.
The second commit addresses a problem with the virtual name() function. If the sort() actually did something (see below), it would try to call the pure virtual name() function before the Check instance was fully constructed. This is likely to crash depending on the library's behaviour when pure virtual functions are called. Each derived class passes its name to the Check constructor(s) which stores it in a local instance variable so the sort has something to compare.
The third commit addresses the sort operation itself. Sorting a list of pointers compares pointer values, not what they point to; the operator<(const Check *) never gets called. This commit specialises std::less
Open Graph Description: I noticed that the instances().sort() in Check::Check() doesn't actually sort anything. The first commit adds a test case to check whether the instances list really is sorted. This should fail....
X Description: I noticed that the instances().sort() in Check::Check() doesn't actually sort anything. The first commit adds a test case to check whether the instances list really is sorted. This should f...
Opengraph URL: https://github.com/cppcheck-opensource/cppcheck/pull/12
X: @github
Domain: github.com
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:824110bf-ce31-3572-dec1-890ae5210228 |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | A46A:322E35:5BF0279:818945B:6A500F40 |
| html-safe-nonce | 3aeddb0518aeb4a8f78f57acf9aeb68954a31ee4eb464efaafdbe56852653e95 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBNDZBOjMyMkUzNTo1QkYwMjc5OjgxODk0NUI6NkE1MDBGNDAiLCJ2aXNpdG9yX2lkIjoiNjY2MjQzOTgyNzgxNDc0Nzk2OCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 500a28fc4ea3d642f795a2213bd15f2d2e5e77b0ffc3b576abbd4de5bffeba5c |
| hovercard-subject-tag | pull_request:65395 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/cppcheck-opensource/cppcheck/pull/12/files |
| twitter:image | https://avatars.githubusercontent.com/u/17221?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/17221?s=400&v=4 |
| og:image:alt | I noticed that the instances().sort() in Check::Check() doesn't actually sort anything. The first commit adds a test case to check whether the instances list really is sorted. This should fail.... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | fe4f38b24922a1ce81c1708c3793b47c185599b9144ab94f6ca846b00698058d |
| turbo-cache-control | no-preview |
| diff-view | unified |
| go-import | github.com/cppcheck-opensource/cppcheck git https://github.com/cppcheck-opensource/cppcheck.git |
| octolytics-dimension-user_id | 278097703 |
| octolytics-dimension-user_login | cppcheck-opensource |
| octolytics-dimension-repository_id | 143131 |
| octolytics-dimension-repository_nwo | cppcheck-opensource/cppcheck |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 143131 |
| octolytics-dimension-repository_network_root_nwo | cppcheck-opensource/cppcheck |
| turbo-body-classes | logged-out env-production page-responsive full-width |
| disable-turbo | true |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 42b6390c91978a16f9196c38c7a00e9bf21f37e7 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width