- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- Re: type-punned pointers!?
Operating System - Linux
1750499
Members
8950
Online
108776
Solutions
Forums
Categories
Company
Local Language
юдл
back
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
юдл
back
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-09-2006 01:16 AM
тАО06-09-2006 01:16 AM
type-punned pointers!?
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
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
2 REPLIES 2
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-09-2006 08:29 AM
тАО06-09-2006 08:29 AM
Re: type-punned pointers!?
>I don't really understand why 'clean' code would give such a warning since it's structures which are defined by the system.
The trouble is that the system headers think they can do anything but don't realize they break strict ANSI C rules. ;-)
You probably can ignore this. I don't know if there is a g++ option to suppress this. Or if the warning will tell g++ not to do that aliasing.
The trouble is that the system headers think they can do anything but don't realize they break strict ANSI C rules. ;-)
You probably can ignore this. I don't know if there is a g++ option to suppress this. Or if the warning will tell g++ not to do that aliasing.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-09-2006 08:50 AM
тАО06-09-2006 08:50 AM
Re: type-punned pointers!?
Yes it seems it's a bug in the system headers.
For now I just fixed the header file /usr/include/sys/_fd_macros.h:
# define FD_SET(n,p) (((__fd_mask *)(void*)((p)->fds_bits))[(n)/_NFDBITS] |...
# define FD_CLR(n,p) (((__fd_mask *)(void*)((p)->fds_bits))[(n)/_NFDBITS] &=...
# define FD_ISSET(n,p) (((__fd_mask *)(void*)((p)->fds_bits))[(n)/_NFDBITS] ...
I have added "(void *)" on all 3 lines. I think it's because the cast is unsafe that I get the complain. On other platforms I'm sure the same thing would have issued "bus errors" which I have experienced in past.
-- Henrik
For now I just fixed the header file /usr/include/sys/_fd_macros.h:
# define FD_SET(n,p) (((__fd_mask *)(void*)((p)->fds_bits))[(n)/_NFDBITS] |...
# define FD_CLR(n,p) (((__fd_mask *)(void*)((p)->fds_bits))[(n)/_NFDBITS] &=...
# define FD_ISSET(n,p) (((__fd_mask *)(void*)((p)->fds_bits))[(n)/_NFDBITS] ...
I have added "(void *)" on all 3 lines. I think it's because the cast is unsafe that I get the complain. On other platforms I'm sure the same thing would have issued "bus errors" which I have experienced in past.
-- Henrik
The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
News and Events
Support
© Copyright 2024 Hewlett Packard Enterprise Development LP