notator.cc:337: abs on unsigned value

Bug #1413108 reported by dcb
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
rumor
Fix Committed
Undecided
Unassigned
Arch Linux
New
Undecided
Unassigned

Bug Description

notator.cc:337:16: warning: taking the absolute value of unsigned type 'unsigned int' has no effect [-Wabsolute-value]

      NumTics=(abs(RefPitch_wt-AbsPitch_wt)+3)/7;

The difference of two unsigneds is unsigned.

If RefPitch_wt < AbsPitch_wt, then wraparound to a large unsigned integer will occur.

Suggest code rework.

Revision history for this message
Stefan Husmann (stefan-husmann) wrote :

Gcc 7 changes the way abs is handled.

The attached patch at least makes rumor build again.

Revision history for this message
Václav Šmilauer (eudoxos) wrote :

Hi Stefan, thank you for the patch. I did not see the bgus reported here for quite some time. I will apply it soon. Cheers! Vaclav

Revision history for this message
Václav Šmilauer (eudoxos) wrote :

I fixed this in the last commit, by casting unsigned operands to signed. If you only remove the abs, then it compiles but changes functionality.

Changed in rumor:
status: New → Fix Committed
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.