avast / avast/retdec

error: cast from int16_t to int32_t loses precision

Open
#1,179 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
8.6k
Forks
1k
PR merge metrics
No merged PRs in 30d

Description

retdec produces code like

```c
int16_t* some_int = NULL;

(int32_t) some_int;
```

which fails to compile

```
main.cpp: error: cast from ‘int16_t*’ {aka ‘short int*’} to ‘int32_t’ {aka ‘int’} loses precision [-fpermissive]
```

related:

- https://stackoverflow.com/questions/8843818/what-does-the-fpermissive-flag-do
- use `CFLAGS="-fpermissive"` to turn errors to warnings
- https://stackoverflow.com/questions/1640423/error-cast-from-void-to-int-loses-precision
- use `static_cast(reinterpret_cast(void * your_variable));`
- https://developerfacts.com/answer/4586808-how-do-i-work-around-the-gcc-error-cast-from-sourcelocation-to-int-loses-precision-error-when-compiling-cmockeryc
- use `CFLAGS="-m32"` to force 32bit target

Contributor guide

No contributing guide indexed for this repository

Research direction

The issue names no source file or test. Start by reproducing the shown generated C++ snippet and trace the RetDec code-generation path that emits the pointer-to-int cast. Done means the affected output compiles without the reported precision-loss error on the relevant target.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
compilers
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
32/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.