You seem to get this on 64 bit compilers that use 64 bit pointers. Converting a 32 bit integer to a 64 bit pointer is questionable and non-portable.

Correct this by using the portable integer type meant to be used for this very purpose:

uintptr_t dst_addr = 0x00FFABCD; 

Now it will compile cleanly on all mainstream 64 bit compilers. Tried on gcc, clang icc with -std=c11 -Wextra -Wall -pedantic-errors, no problems.

In addition, when accessing an absolute address, you will almost certainly need to volatile qualify the pointer.

Answer from Lundin on Stack Overflow
🌐
Parasoft Forums
forums.parasoft.com › c/c++test
Parasoft C/C++Test 9.4 , error: invalid type conversion — Parasoft Forums
August 8, 2022 - "/usr/lib/gcc/x86_64-pc-cygwin/11/include/mmintrin.h", line 79: error: invalid type conversion return (__m64) __builtin_ia32_vec_init_v2si (__i, 0); ^ "/usr/lib/gcc/x86_64-pc-cygwin/11/include/mmintrin.h", line 161: error: invalid type conversion return (__m64) __builtin_ia32_packsswb ((__v4hi)__m1, (__v4hi)__m2); ^ "/usr/lib/gcc/x86_64-pc-cygwin/11/include/mmintrin.h", line 176: error: invalid type conversion return (__m64) __builtin_ia32_packssdw ((__v2si)__m1, (__v2si)__m2); ^ "/usr/lib/gcc/x86_64-pc-cygwin/11/include/mmintrin.h", line 191: error: invalid type conversion return (__m64) __builtin_ia32_packuswb ((__v4hi)__m1, (__v4hi)__m2); ^ "/usr/lib/gcc/x86_64-pc-cygwin/11/include/mmintrin.h", line 205: error: invalid type conversion return (__m64) __builtin_ia32_punpckhbw ((__v8qi)__m1, (__v8qi)__m2); ^ ...
Discussions

CCS :: View topic - Invalid type conversion?
Profile Log in to check your private messages Log in · CCS does not monitor this forum on a regular basis More on ccsinfo.com
🌐 ccsinfo.com
misra - Invalid type conversion while using ANSI c - Stack Overflow
I am facing this problem as when I am trying to build the code using ANSI C, as I was practicing writing in it and dealing with its rules, it tells me invalid type conversion and I don't know what ... More on stackoverflow.com
🌐 stackoverflow.com
"invalid type" error
In C, types are in many situations implicitly converted to the required type. This is expected behaviour so you don't get a warning. More on reddit.com
🌐 r/C_Programming
18
7
April 18, 2019
c++ - Invalid type conversion using static_cast, what proper casting should I use? - Stack Overflow
Then I try to use static_cast, but I got an error saying Invalid type conversion More on stackoverflow.com
🌐 stackoverflow.com
🌐
Cprogramming
cboard.cprogramming.com › c-programming › 180959-trying-make-following-work-but-getting-invalid-type-conversion.html
Trying to make the following work but getting invalid type conversion?
March 20, 2022 - If the struct members really are the same type (a uint16_t) and represent the same information (a voltage), then you could do this. ... void voltage(t_SenseDataRaw *k, float *adv) { uint16_t p = &k->Vbias; // the first member for (int i = 0; i < 4; i++) adv[i] = p[i] * 3.3 / 4096; } If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
🌐
GitHub
github.com › microsoft › vscode-cpptools › issues › 11294
invalid type conversion IntelliSense · Issue #11294 · microsoft/vscode-cpptools
August 5, 2023 - [{ "resource": "/C:/Test/bug_report/main.cpp", "owner": "C/C++: IntelliSense", "code": "171", "severity": 8, "message": "invalid type conversion", "source": "C/C++", "startLineNumber": 4, "startColumn": 4, "endLineNumber": 4, "endColumn": 8 }] In fact the same error is seeing in visual studio 2022 but again the code compiles without any problem ·
🌐
Compiler Warnings
compilerwarnings.weebly.com › blog › error-171-invalid-type-conversion
Error: [#171] invalid type conversion - Compiler Warnings
October 20, 2016 - ​SRC\file.c:327: error: [#171] invalid type conversion Reason: Trying to "type cast", where it is impossible for compiler (types are not compatible). Examples: void vs struct vs int/double It can...
🌐
Developer Community
developercommunity.visualstudio.com › content › problem › 1311096 › vs2019-c-compiler-allows-invalid-type-conversion-n.html
VS2019 C++ Compiler Allows Invalid Type Conversion ...
January 15, 2021 - Skip to main content · Microsoft · Visual Studio · Sign in · You need to enable JavaScript to run this app · Sorry this browser is no longer supported · Please use any other modern browser like 'Microsoft Edge'
🌐
CCS, Inc.
ccsinfo.com › forum › viewtopic.php
CCS :: View topic - Invalid type conversion?
Profile Log in to check your private messages Log in · CCS does not monitor this forum on a regular basis
🌐
Texas Instruments E2E
e2e.ti.com › support › microcontrollers › c2000-microcontrollers-group › c2000 › f › c2000-microcontrollers-forum › 991988 › tms320f28379d-including-driverlib-in-cla-file-issues-warning-173-d-invalid-type-conversion
TMS320F28379D: Including DriverLib in CLA File Issues warning #173-D: invalid type conversion
April 7, 2021 - "C:/ti/c2000/C2000Ware_3_04_00_00/driverlib/f2837xd/driverlib/adc.h", line 1876: warning #173-D: invalid type conversion "C:/ti/c2000/C2000Ware_3_04_00_00/driverlib/f2837xd/driverlib/adc.h", line 1877: warning #173-D: invalid type conversion "C:/ti/c2000/C2000Ware_3_04_00_00/driverlib/f283...
Find elsewhere
🌐
Stack Overflow
stackoverflow.com › questions › 73091181 › invalid-type-conversion-while-using-ansi-c
misra - Invalid type conversion while using ANSI c - Stack Overflow
If I understand correctly, you are trying to cast an existing function to match a function pointer declaration that has a differing argument type. You can cast the parameters and call such a function, but because function pointers themselves may be used anywhere in the program, at the places where they would be used the code would not know what to cast (which may result in a size difference) this is illegal. ... Because this pointer to function does expect any return I removed the cast, it removed the invalid conversion type error but kept this one expression preceding parentheses of apparent call must have (pointer-to-) function type, Is what I did right?
🌐
Reddit
reddit.com › r/c_programming › "invalid type" error
r/C_Programming on Reddit: "invalid type" error
April 18, 2019 -

Why do I get no warnings/errors with:

/* test.c */

#include <stdio.h>

void calculate(int a){
	a = a + 1;
	printf("a = %i\n",a);
};

int main(void)
{
	float c = 7.0;
	
	calculate(c);
	
	return 0;
};

Output:

a = 8

I am passing a float to a function that expects int. It seems the compiler is doing some type of behind the scenes type conversion.

I am compiling using gcc 8.3.1 using the command

gcc test.c -Wextra -Wall

Should I get a "invalid type" error or am I going slightly mad?

🌐
php.cn
m.php.cn › home › backend development › c++ › c++ compilation error: invalid type conversion, how to deal with it?
C++ compilation error: Invalid type conversion, how to deal with it?-C++-php.cn
In C, type conversion will occur in the assignment statement, such as assigning a string constant to a character array variable. But if the lengths of the two data types do not match, or the format of the string constant is incorrect, an "invalid ...
🌐
CFD Online
cfd-online.com › Forums › fluent › 220163-how-remove-invalid-type-conversion-double-pointer-char-error.html
How to remove "invalid type conversion: double -> pointer to char" Error? -- CFD Online Discussion Forums
August 27, 2019 - I have written a UDF to define the Specific Heat of the PCM in the melting range by the following equation Cp= (1934+(131*(temp-300.35))+(245000*((exp(
🌐
CCS, Inc.
ccsinfo.com › forum › viewtopic.php
CCS :: View topic - Unexpected "Invalid Type Conversion" Error
Profile Log in to check your private messages Log in · CCS does not monitor this forum on a regular basis
🌐
Stack Overflow
stackoverflow.com › questions › 73526960 › on-control-range-c-error-invalid-type-conversion
visual studio - ON_CONTROL_RANGE C++ error invalid type conversion - Stack Overflow
E0171 invalid type conversion · why is this error comes up, give me a hint · Code · #define IDC_USR_MANUAL_TUNING_CH1_CHECK 1134 #define IDC_USR_MANUAL_TUNING_CH7_CHECK 1140 ON_CONTROL_RANGE(BN_CLICKED, IDC_USR_MANUAL_TUNING_CH1_CHECK, IDC_USR_MANUAL_TUNING_CH8_CHECK, OnUsrManualTuningChCheck) void CMainteManualTuningDialog::OnUsrManualTuningChCheck(int nId) { if (FALSE == m_bInitFlag) // Initialization flag TRUE: Initialized / FALSE: Uninitialized { return; } UpdateData(TRUE); int nChCnt = nId - IDC_USR_MANUAL_TUNING_CH1_CHECK; if ((CH1 > nChCnt) || (CH8 < nChCnt)) { return; } // unused if
🌐
Stack Overflow
stackoverflow.com › questions › 73272550 › parasoft-c-ctest-9-4-error-invalid-type-conversion
unit testing - Parasoft C/C++Test 9.4 , error: invalid type conversion - Stack Overflow
August 8, 2022 - "/usr/lib/gcc/x86_64-pc-cygwin/11/include/mmintrin.h", line 79: error: invalid type conversion return (__m64) __builtin_ia32_vec_init_v2si (__i, 0); ^ "/usr/lib/gcc/x86_64-pc-cygwin/11/include/mmintrin.h", line 161: error: invalid type conversion return (__m64) __builtin_ia32_packsswb ...
🌐
Cppreference
en.cppreference.com › w › cpp › language › static_cast.html
static_cast conversion - cppreference.com
Otherwise, the result is a pointer to the object of type Derived enclosing the object of type Base pointed to by expression. If any of the following conditions is satisfied, the program is ill-formed: Base is a virtual base class of Derived. Base is a base class of a virtual base class of Derived. No valid standard conversion from “pointer to Derived” to “pointer to Base” exists.
🌐
Cplusplus
cplusplus.com › doc › tutorial › typecasting
Type-cast
If the conversion is from a floating-point type to an integer type, the value is truncated (the decimal part is removed). If the result lies outside the range of representable values by the type, the conversion causes undefined behavior.