|
Boost Users : |
Subject: [Boost-users] signals2::slot_type & g++ anti-aliasing warning
From: Ãkos Maróy (akos_at_[hidden])
Date: 2010-11-08 03:44:41
Hi,
I bumped into an issue, where g++ would give me an anti-aliasing warning
for very basic / straightforward signals2 code. consider the following
sample code:
#include <iostream>
#include <boost/bind.hpp>
#include <boost/signals2.hpp>
typedef boost::signals2::signal<void (void)> sig_t;
void ff(void) {
std::cout << "ff" << std::endl;
}
int main(void) {
sig_t::slot_type ss = boost::bind(&ff);
return 0;
}
when compiled with the -Wall and -O2 flags, I get the following compiler
warning:
...
sample.cxx:13: instantiated from here
/home/maroy/src/mxp/usr/include/boost/function/function_base.hpp:321:
warning: dereferencing type-punned pointer will break strict-aliasing rules
/home/maroy/src/mxp/usr/include/boost/function/function_base.hpp:325:
warning: dereferencing type-punned pointer will break strict-aliasing rules
(I can provide the full compiler output if needed)
this is with boost 1.44 on a linux x86_64, g++ version 4.4.3
omitting either the -O2 or the -Wall flags will make the warning go away.
what am I doing wrong?
Akos
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net