[Info-vax] C troubles: BADSTATICCVT

Craig A. Berry craigberry at nospam.mac.com
Fri Feb 2 09:06:37 EST 2018


On 2/2/18 7:18 AM, hb wrote:
> On 02/02/2018 12:49 AM, Craig A. Berry wrote:
>> $ cc static_const1
>>
>>      42, (intptr_t)"."
>> ..................^
>> %CC-E-BADSTATICCVT, In the initializer for mydata[0].nonsense, the
>> address cannot be converted to the destination type.
>> at line number 9 in file D0:[craig.TEST]static_const1.c;3
>>
>> HELP CC MESSAGES BADSTATICCVT tells me, "A static initialization tried
>> to convert a link-time address to another type. However, the linker on
>> this platform will not support such a conversion." And also that I
>> should, "Rewrite the static initialization, or perform the
>> initialization using runtime code."
> 
> Probably someone else can and will explain the error code (to me it
> looks like the compiler hesitates to issue a relocation the linker can't
> process) I only observed that without the cast, there is an additional
> warning
> 
> $ cc static_const1.c/pointer=64
> 
>      42, "."
> ........^
> %CC-W-CVTDIFTYPES, In the initializer for mydata[0].nonsense, ""."" of
> type "short pointer to char", is being converted to "__int64".
> 
> As a workaround, you may want to cast to int32_t. This seems to work for
> HP C V7.3-010 on OpenVMS Alpha V8.4-2L2.

Aha. So it does. Which means this is probably yet more fallout from the
mongrel 64-bit pointer implementation since intptr_t is 64 bits on
non-VAX regardless of whether the pointers are 32-bit or 64-bit. So
trying to convert a 32-bit address into a 64-bit integer is not
something it can do at compile time.

But there must be more to the story as compiling with /POINTER_SIZE=64
doesn't fix it.




More information about the Info-vax mailing list