Podger2016 / rapidjson

Automatically exported from code.google.com/p/rapidjson
0 stars 0 forks source link

old style cast to 'void*' casts away const in document.h #46

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Compile with gcc 4.7.2 using -Werror=cast-qual

What version of the product are you using? On what operating system?

     rapidjson 0.1.

Please provide any additional information below.

In the destructor ~GenericValue() there is a line like this:

     Allocator::Free((void*)data_.s.str);

That line seems wrong - It casts away const.

The minimal fix (assuming that the logic is otherwise correct) is to change 
this to:

     Allocator::Free(const_cast<void*>((const void*)data_.s.str));

Original issue reported on code.google.com by lundb...@gmail.com on 14 Nov 2012 at 12:05

GoogleCodeExporter commented 8 years ago
I don't have gcc 4.7.x installed yet.

I used gcc 4.5.3 and found another casting issue in SetStringRaw().

I propose the following patch:

Allocator::Free(const_cast<Ch*>(data_.s.str));

Would you help me to verify this patch in gcc 4.7.x?

Original comment by milo...@gmail.com on 15 Nov 2012 at 3:14

GoogleCodeExporter commented 8 years ago
This issue was closed by revision r88.

Original comment by milo...@gmail.com on 15 Nov 2012 at 3:46

GoogleCodeExporter commented 8 years ago
Hi. Yes that solution works fine her also, and is better.

Original comment by lundb...@gmail.com on 19 Nov 2012 at 3:06

GoogleCodeExporter commented 8 years ago
This issue was closed by revision 90f983ced2aa.

Original comment by milo...@gmail.com on 6 Jun 2014 at 6:04