On Wed, Jun 07, 2017 at 05:16:44PM +0300, K wrote:
> > ui16 *ptr = (ui16*)buf;
> >
> > There's no need for any of this messing about with pointer casts, as has
> > been explained.
> >
>
> Sorry, but I still can't get the idea. Cast from udp_pseudo to uint8_t
> doesn't have an aliasing
On 06/07/2017 04:56 PM, Andrew Haley wrote:
On 07/06/17 14:45, K wrote:
And I found that that a version which I beleve mustn't have aliasing
problems still generates same warnings.
It still has aliasing problems: you can't make them magically go away
by using an intermediate uint8_t*.
You're
On 07/06/17 14:45, K wrote:
> And I found that that a version which I beleve mustn't have aliasing
> problems still generates same warnings.
It still has aliasing problems: you can't make them magically go away
by using an intermediate uint8_t*.
You're doing this:
struct udp_pseudo {
That snippet invokes undefined behavior at runtime (violates C++ aliasing
rules),
so just fix it, rather than bother with bugreports. E.g. look for
-fstrict-aliasing
in GCC documentation, or read the C++ standard. With -fno-strict-aliasing,
which is a workaround for broken code you won't ge
On 07/06/17 11:33, Andrew Haley wrote:
> On 07/06/17 10:15, Kirill Yu Berezin wrote:
>> My question is. Is this an expected behaviour or I must report a bug ?
>
> It's not a bug: your code displays undefined behaviour: you're casting
> a pointer to struct udp_pseudo fields to an array of uint16_t.
On 07/06/17 10:15, Kirill Yu Berezin wrote:
> My question is. Is this an expected behaviour or I must report a bug ?
It's not a bug: your code displays undefined behaviour: you're casting
a pointer to struct udp_pseudo fields to an array of uint16_t. This
is never well-defined in C++, but if you
On Wed, Jun 07, 2017 at 12:15:54PM +0300, Kirill Yu Berezin wrote:
> Hello!
>
> I have a code snippet (actually it is a part of larger project):
That snippet invokes undefined behavior at runtime (violates C++ aliasing
rules),
so just fix it, rather than bother with bugreports. E.g. look for
-
Hello!
I have a code snippet (actually it is a part of larger project):
#include
#define UDP_PROTO_NUMBER 17
uint32_t calc_16bit_checksum_part(uint8_t* buf, int len, uint32_t ret) {
uint16_t *ptr = reinterpret_cast(buf);
int i;
for( i = 0; i < (len / 2); ++i) {