Issue 28 in libfixmath: Unary minus on unsigned type

18 views
Skip to first unread message

libfi...@googlecode.com

unread,
Jan 15, 2014, 5:27:33 PM1/15/14
to libfi...@googlegroups.com
Status: New
Owner: ----
Labels: Type-Defect Priority-Medium

New issue 28 by sunside...@gmail.com: Unary minus on unsigned type
http://code.google.com/p/libfixmath/issues/detail?id=28

# What steps will reproduce the problem?
1. Compile the sources in Microsoft Visual Studio with /TP flag (compile as
C++ to enable C99-like mode)

# What is the expected output? What do you see instead?
Expect passing build, but get the following errors:

- error C4146: unary minus operator applied to unsigned type, result still
unsigned fract32.c:24
- error C4146: unary minus operator applied to unsigned type, result still
unsigned fix16_sqrt32.c:83

# What version of the product are you using? On what operating system?
Microsoft Visual Studio 2013, Windows 8 - should be unrelated

# Please provide any additional information below.
Both functions return signed values. The problem comes from the fact that
the returned values themselves are unsigned yet have the unary minus
operator. Since they are unsigned, applying minus is meaningless.

Explicitly casting the values resolves the problem, so that, for example
return -fract32_usmul(-inVal, inFract);
reads
return -(int32_t)fract32_usmul(-inVal, inFract);

A patch file is attached.

Attachments:
signedfix.patch 678 bytes

--
You received this message because this project is configured to send all
issue notifications to this address.
You may adjust your notification preferences at:
https://code.google.com/hosting/settings

libfi...@googlecode.com

unread,
Jan 16, 2014, 1:22:27 AM1/16/14
to libfi...@googlegroups.com
Updates:
Status: Fixed

Comment #1 on issue 28 by Petteri.Aimonen: Unary minus on unsigned type
http://code.google.com/p/libfixmath/issues/detail?id=28

Thanks. Patch committed in r90.
Reply all
Reply to author
Forward
0 new messages