Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

a warning when a pointer is cast to a smaller size

26 views
Skip to first unread message

kzelec...@e3tech.local

unread,
Apr 18, 2013, 4:53:06 AM4/18/13
to
Given that lcc does not provide type intptr_t, I would appreciate a warning
on this code:
void foo (int * p) { int x = (char) p; }
Warning: irreversible pointer cast
Best regards,
Chris

jacob navia

unread,
Apr 18, 2013, 7:31:58 AM4/18/13
to
Le 18/04/13 10:53, kzelec...@e3tech.local a �crit :
> void foo (int * p) { int x = (char) p; }

Using lcc-win I get

"Pointer truncation when converting to char"

Both in 32 and 64 bit versions.

kzelec...@e3tech.local

unread,
Apr 18, 2013, 7:45:52 AM4/18/13
to
I get
conversion from `pointer to int' to `char' is compiler dependent
but only from lcc -A (which, BTW, sort of solves the problem). However, -A
is undocumented under "Lcc command line switches", except in the PDF.

U�ytkownik "jacob navia" napisa� w wiadomo�ci grup
dyskusyjnych:kkoljd$edr$1...@speranza.aioe.org...

jacob navia

unread,
Apr 18, 2013, 8:13:54 AM4/18/13
to
Le 18/04/13 13:45, kzelec...@e3tech.local a �crit :
> I get
> conversion from `pointer to int' to `char' is compiler dependent
> but only from lcc -A (which, BTW, sort of solves the problem). However,
> -A is undocumented under "Lcc command line switches", except in the PDF.
>

You are using the original version of lcc then. I have been working for
years improving it, and the result is lcc-win.


kzelec...@e3tech.local

unread,
Apr 18, 2013, 10:21:05 AM4/18/13
to
Here is what I am using:

Logiciels/Informatique lcc-win32 version 2.4.1 MathWorks patch 1.43
compilation date: Apr 9 2010 14:41:21

U�ytkownik "jacob navia" napisa� w wiadomo�ci grup
dyskusyjnych:kkoo1u$m94$1...@speranza.aioe.org...

jacob navia

unread,
Apr 18, 2013, 11:25:55 AM4/18/13
to
Le 18/04/13 16:21, kzelec...@e3tech.local a �crit :
> Here is what I am using:
>
> Logiciels/Informatique lcc-win32 version 2.4.1 MathWorks patch 1.43
> compilation date: Apr 9 2010 14:41:21
>

Ahhh ok. That is the version of lcc-win maintained by Mathworks from
2010. In that case you should file a bug report to Mathworks, they
maintain that version.

jacob


Keith Thompson

unread,
Apr 18, 2013, 11:40:25 AM4/18/13
to
<kzelec...@e3tech.local> writes:
> Here is what I am using:
>
> Logiciels/Informatique lcc-win32 version 2.4.1 MathWorks patch 1.43
> compilation date: Apr 9 2010 14:41:21
>
> U�ytkownik "jacob navia" napisa� w wiadomo�ci grup
> dyskusyjnych:kkoo1u$m94$1...@speranza.aioe.org...
>
> Le 18/04/13 13:45, kzelec...@e3tech.local a �crit :
>> I get
>> conversion from `pointer to int' to `char' is compiler dependent
>> but only from lcc -A (which, BTW, sort of solves the problem). However,
>> -A is undocumented under "Lcc command line switches", except in the PDF.
>>
>
> You are using the original version of lcc then. I have been working for
> years improving it, and the result is lcc-win.

If it's a version of lcc-win, I'm surprised it doesn't support intptr_t.
Do you have `#include <stdint.h>`?

In any case, support or lack of support for intptr_t doesn't seem
relevant to whether that conversion should trigger a warning.

--
Keith Thompson (The_Other_Keith) ks...@mib.org <http://www.ghoti.net/~kst>
Working, but not speaking, for JetHead Development, Inc.
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"

kzelec...@e3tech.local

unread,
Apr 19, 2013, 2:19:27 AM4/19/13
to
I do not have <stdint.h> in lcc-win32 version 2.4.1 MathWorks patch 1.43, so
there is no numeric type I can safely use for a pointer masqueraded as a
number; I have to maintain some context in the server, I cannot return a
pointer to the client and I am too lazy to implement my handle map.
Therefore if I suddenly use an integer type too small to hold a pointer, I
would like to be warned about it. If I had intptr_t, I would just use that
NQA.

Of course, I can always assert that the conversion does not lose data at run
time.

Użytkownik "Keith Thompson" napisał w wiadomości grup
dyskusyjnych:ln38unh...@nuthaus.mib.org...

<kzelec...@e3tech.local> writes:
> Here is what I am using:
>
> Logiciels/Informatique lcc-win32 version 2.4.1 MathWorks patch 1.43
> compilation date: Apr 9 2010 14:41:21
>
> U¿ytkownik "jacob navia" napisa³ w wiadomo¶ci grup
> dyskusyjnych:kkoo1u$m94$1...@speranza.aioe.org...
>
> Le 18/04/13 13:45, kzelec...@e3tech.local a écrit :
0 new messages