Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in
  • SWIFTsim SWIFTsim
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 57
    • Issues 57
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 21
    • Merge requests 21
  • Deployments
    • Deployments
    • Releases
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Commits
  • Issue Boards
Collapse sidebar
  • SWIFT
  • SWIFTsimSWIFTsim
  • Merge requests
  • !55

Removed an unecessary condition that GCC optimizes out and produces a warning blocking compilation.

  • Review changes

  • Download
  • Email patches
  • Plain diff
Merged Matthieu Schaller requested to merge Sorting_fix into master Oct 28, 2015
  • Overview 0
  • Commits 1
  • Changes

GCC 5.x.y returns a lethal warning when compiling the code:

space.c: In function 'parts_sort': space.c:595:12: error: assuming signed overflow does not occur when assuming that (X + c) < X is always false [-Werror=strict-overflow] if (jj + 1 < j && pivot + 1 < max) { ^ space.c: In function 'gparts_sort': space.c:735:12: error: assuming signed overflow does not occur when assuming that (X + c) < X is always false [-Werror=strict-overflow] if (jj + 1 < j && pivot + 1 < max) {

After some research it turns out that the compiler notices that the condition "jj + 1<j" is always true and attempts to optimize it out. But it is only true if j and jj don't overflow (which is what we want anyway). So since it is an "unsafe" optimisation, the compiler returns a warning and we die on warnings...

In this patch I completely remove that condition. Do you agree with that fix ?

Note that the parallel_sort branch suffers from the same issue.

Assignee
Assign to
Reviewers
Request review from
Time tracking
Source branch: Sorting_fix