Commit 030f6d1
committed
Symbol.cc and FileStream.cc: Fix -Wconversion and -Wuseless-cast on 32-bit builds
Symbol.cc:
it - rs.begin() returns a value of type std::ptrdiff_t.
On 32-bit systems, this is typically int, so casting it to int is redundant
and triggers -Wuseless-cast.
FileStream.cc:
size_t is 32-bit on 32-bit systems, while position is int64_t.
Casting int64_t to size_t can lead to truncation, causing -Wconversion errors.
The fix ensures the offset and position are checked for negativity before conversion.
Fix:
lib32-avro-c++/1.12/sources/avro-c++-1.12/lang/c++/impl/parsing/Symbol.cc:91:27:
error: useless cast to type 'int' [-Werror=useless-cast]
91 | adj.push_back(static_cast<int>(it - rs.begin()));
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cc1plus: all warnings being treated as errors
lib32-avro-c++/1.12/sources/avro-c++-1.12/lang/c++/impl/FileStream.cc:208:41:
error: conversion from 'int64_t' {aka 'long long int'} to 'size_t'
{aka 'unsigned int'} may change value [-Werror=conversion]
208 | in_->seek(position - byteCount_ - available_);
| ~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~
lib32-avro-c++/1.12/sources/avro-c++-1.12/lang/c++/impl/FileStream.cc:209:22:
error: conversion from 'int64_t' {aka 'long long int'} to 'size_t'
{aka 'unsigned int'} may change value [-Werror=conversion]
209 | byteCount_ = position;
| ^~~~~~~~
cc1plus: all warnings being treated as errors
These changes fix build failures on 32-bit systems and ensure safe type conversions.
Signed-off-by: Alper Ak <alperyasinak1@gmail.com>1 parent 0997c33 commit 030f6d1
2 files changed
+15
-3
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
205 | 205 | | |
206 | 206 | | |
207 | 207 | | |
208 | | - | |
209 | | - | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
210 | 217 | | |
211 | 218 | | |
212 | 219 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
88 | 88 | | |
89 | 89 | | |
90 | 90 | | |
91 | | - | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
92 | 97 | | |
93 | 98 | | |
94 | 99 | | |
| |||
0 commit comments