type-punned pointers!?

H

Henrik Goldman

Hi,

I'm seeing a weird problem on hp-ux (ia64) using g++ 4.1.1.

Here below is a tiny bit of code which sets up the nessecary code for doing
a select():

fd_set fdread, fdwrite;

FD_ZERO(&fdread);

FD_ZERO(&fdwrite);

FD_SET(m_IncomingSocket.GetSocket(), &fdread);

FD_SET(m_IncomingSocket.GetSocket(), &fdwrite);

For the last two lines I get the following warning:

warning: dereferencing type-punned pointer will break strict-aliasing rules
warning: dereferencing type-punned pointer will break strict-aliasing rules

I don't really understand why 'clean' code would give such a warning since
it's structures which are defined by the system.
However perhaps someone could tell me what it actually means and eventually
how to solve it? My g++ optimization is O2.

Thanks in advance.
-- Henrik
 
V

Victor Bazarov

Henrik said:
I'm seeing a weird problem on hp-ux (ia64) using g++ 4.1.1.

Have you tried ? If not, why not? If you have, what
did you find out?
Here below is a tiny bit of code which sets up the nessecary code for
doing a select():

fd_set fdread, fdwrite;

Are we supposed to know what 'fd_set' is?
FD_ZERO(&fdread);

FD_ZERO(&fdwrite);

FD_SET(m_IncomingSocket.GetSocket(), &fdread);

FD_SET(m_IncomingSocket.GetSocket(), &fdwrite);

Those 'FD_' things look like macros. How are they defined?
For the last two lines I get the following warning:

warning: dereferencing type-punned pointer will break strict-aliasing
rules warning: dereferencing type-punned pointer will break
strict-aliasing rules
I don't really understand why 'clean' code

What makes you believe the code is "'clean'"? What does it mean,
exactly?
would give such a warning
since it's structures which are defined by the system.
However perhaps someone could tell me what it actually means and
eventually how to solve it? My g++ optimization is O2.

If you haven't tried yet, go try it. Also, they
have an online forum (on their web site), IIRC. Don't discount it.
It's much more suitable for questions on a particular compiler's
behaviour than c.l.c++.

V
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,228
Members
46,817
Latest member
AdalbertoT

Latest Threads

Top