Previous mail
Next mail
Unformatted/full headers
Overview 10 days
Subject
Date
Thread
Author
From: Adriaan van Os
Subject: cast increases required alignment of
Date: 10 Sep 2004, 17:36:29
Frank Heckenbach wrote:
>> 1. Compiling with gpc produces two warnings as indicated in the
>> comment. The compiler warns if the "casting" pointer type (outside the
>> parenthesis) points to a larger type than the "casted" pointer type
>> (inside the parenthesis).
>
> Not really. As the message says, it warns that the alignment, not
> size, of the target type is larger.
>
>> Gale Paper brought to my attention that the
>> same holds on the left side of an assignment and I am inclined to
>> regard this as a bug - the compiler should check here for a smaller
>> type, rather than a larger type.
>
> While casting to a smaller type can be dangerous in some cases, so
> can any pointer conversion, so I'm not convinced that this case
> deserves particular attention.
Well, OK, the warning is about alignments not about sizes. Thanks for
pointing that out.
Still I am not convinced that
theIntPtr:= IntPtr( theBytePtr); {testcast.pas:11: warning: cast
increases required alignment of target type}
should produce a warning and left-side equivalent shouldn't
BytePtr( theIntPtr) := theBytePtr;
Both statements have the same effect. Actually, the target is in both
cases a variable of type Integer. So, at the left side of an
assignment, the target is the innermost type of the cast, not the
outermost.
The same remarks apply for
theBytePtr:= BytePtr( theIntPtr);
IntPtr( theBytePtr):= theIntPtr; {testcast.pas:14: warning: cast
increases required alignment of target type}
but then the other way round.
Regards,
Adriaan van Os
Previous mail
Next mail
Unformatted/full headers
Overview 10 days
Subject
Date
Thread
Author
| Author | Subject | Date |
|---|---|---|
| Frank Heckenbach | cast increases required alignment of | 6 Sep 2004, 19:08:33 |
Note: This page contains information that does not originate from the owner of this web site, but from the authors of the mails archived. The owner of this web site is not responsible for the content of such information. Any use of that infomation requires the consent of the respective author.
Where WWW addresses (URLs) in the mails archived are marked as hyperlinks, this is only for the comfort of the reader. The content of the web pages linked to like this does not necessarily reflect the opinion of the owner of this web site or of the authors of the mails archived. The owner of this web site is not responsible for the content of such web pages. Those pages are explicitly not to be considered as part of the content of this page, but merely as references.
This page was created by Crystal 0.999 (Linux 2.4.27/i686).