[Info-vax] C troubles: BADSTATICCVT
johnwallace4 at yahoo.co.uk
johnwallace4 at yahoo.co.uk
Fri Feb 2 09:26:21 EST 2018
On Friday, 2 February 2018 14:06:41 UTC, Craig A. Berry wrote:
> 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.
When I was looking at similar weirdness with a custom
variant of gcc 3.4.4 (?) some time ago, I ended up being
far too familiar with the object file innards (ELF,
DWARF, etc) than I wanted to be.
I'm not recommending that kind of approach, but sometimes
it can be informative, especially in the absence of
other error info.
More information about the Info-vax
mailing list