[Bug libstdc++/31638] New: [4.0/4.1/4.2/4.3 Regression] string usage leads to warning with -Wcast-align
tbm at cyrius dot com
gcc-bugzilla@gcc.gnu.org
Thu Apr 19 23:45:00 GMT 2007
[ Forwarded from http://bugs.debian.org/382153 This issue has been reported
by Margarita Manterola who also provided the testcase ]
If you compile the following testcase with -Wcast-align you get a warning
on certain architectures, including alpha, arm, hppa, ia64 and sparc.
I've verified this on ia64 with gcc 4.0, 4.1 and 4.3. 3.3 and 3.4 don't
show this warning. The warning goes away when you include <iostream> in
addition to <string>.
tbm@coconut0:~/src$ /usr/lib/gcc-snapshot/bin/g++ -Wcast-align x.c
/usr/lib/gcc-snapshot/lib/gcc/ia64-linux-gnu/4.3.0/../../../../include/c++/4.3.0/bits/basic_string.h:
In member function 'std::basic_string<_CharT, _Traits, _Alloc>::_Rep*
std::basic_string<_CharT, _Traits, _Alloc>::_M_rep() const [with _CharT = char,
_Traits = std::char_traits<char>, _Alloc = std::allocator<char>]':
/usr/lib/gcc-snapshot/lib/gcc/ia64-linux-gnu/4.3.0/../../../../include/c++/4.3.0/bits/basic_string.h:496:
instantiated from 'std::basic_string<_CharT, _Traits,
_Alloc>::~basic_string() [with _CharT = char, _Traits = std::char_traits<char>,
_Alloc = std::allocator<char>]'
x.c:6: instantiated from here
/usr/lib/gcc-snapshot/lib/gcc/ia64-linux-gnu/4.3.0/../../../../include/c++/4.3.0/bits/basic_string.h:288:
warning: cast from 'char*' to 'std::basic_string<char, std::char_traits<char>,
std::allocator<char> >::_Rep*' increases required alignment of target type
Testcase:
#include <string>
using namespace std;
int main (int argc, char **argv) {
string hi;
hi = "Hi";
return 0;
}
--
Summary: [4.0/4.1/4.2/4.3 Regression] string usage leads to
warning with -Wcast-align
Product: gcc
Version: 4.3.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: libstdc++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: tbm at cyrius dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31638
More information about the Gcc-bugs
mailing list