C++ Fix16 cast operators should be const.
Closed this issue · 1 comments
GoogleCodeExporter commented
What steps will reproduce the problem?
1. Compile
Fix16 a(2.0);
Fix16 b(4.0);
int16_t c = a+b;
What is the expected output? What do you see instead?
We get the error:
error: passing ‘const Fix16’ as ‘this’ argument of ‘Fix16::operator int16_t()’ discards qualifiers [-fpermissive]
This code should, IMHO, successfully compile with no warning.
The problem is that the operator+() method returns a const Fix16, on which we
call operator int16_t() which is not const, and can not apply on that object.
Attached is a (very simple) fix (just setting all cast operators as const).
What version of the product are you using? On what operating system?
Latest svn revision.
Original issue reported on code.google.com by louizat...@gmail.com
on 2 Jul 2012 at 4:01
Attachments:
GoogleCodeExporter commented
Agreed and done.
If you find yourself using this project a lot and think you could offer more
useful patches then I'll gladly set you up as a contributor.
Original comment by Flatmush@googlemail.com
on 2 Jul 2012 at 4:09
- Changed state: Fixed