summaryrefslogtreecommitdiffstats
path: root/libstdc++-v3
diff options
context:
space:
mode:
authorpaolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4>2005-11-24 01:29:51 +0000
committerpaolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4>2005-11-24 01:29:51 +0000
commit79a1c1d7265d640cdc5a235953158b4d22e9e9a8 (patch)
treed1a0f1aebbb9a1bd9dea8d13348355584ec30650 /libstdc++-v3
parent558b716ae96e387caeb5ed07d46e9e8fb2bdca51 (diff)
downloadppe42-gcc-79a1c1d7265d640cdc5a235953158b4d22e9e9a8.tar.gz
ppe42-gcc-79a1c1d7265d640cdc5a235953158b4d22e9e9a8.zip
2005-11-23 Paolo Carlini <pcarlini@suse.de>
PR libstdc++/24975 (basic_string) * include/bits/basic_string.h (_Rep::_S_empty_rep): Avoid strict-aliasing warnings. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@107447 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libstdc++-v3')
-rw-r--r--libstdc++-v3/ChangeLog6
-rw-r--r--libstdc++-v3/include/bits/basic_string.h8
2 files changed, 13 insertions, 1 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index 8517757ea00..d0f773dfb58 100644
--- a/libstdc++-v3/ChangeLog
+++ b/libstdc++-v3/ChangeLog
@@ -1,3 +1,9 @@
+2005-11-23 Paolo Carlini <pcarlini@suse.de>
+
+ PR libstdc++/24975 (basic_string)
+ * include/bits/basic_string.h (_Rep::_S_empty_rep): Avoid
+ strict-aliasing warnings.
+
2005-11-22 Paolo Carlini <pcarlini@suse.de>
PR libstdc++/24975
diff --git a/libstdc++-v3/include/bits/basic_string.h b/libstdc++-v3/include/bits/basic_string.h
index 8f35b15a07c..8623c8db7fe 100644
--- a/libstdc++-v3/include/bits/basic_string.h
+++ b/libstdc++-v3/include/bits/basic_string.h
@@ -177,7 +177,13 @@ namespace std
static _Rep&
_S_empty_rep()
- { return *reinterpret_cast<_Rep*>(&_S_empty_rep_storage); }
+ {
+ // NB: Mild hack to avoid strict-aliasing warnings. Note that
+ // _S_empty_rep_storage is never modified and the punning should
+ // be reasonably safe in this case.
+ void* __p = reinterpret_cast<void*>(&_S_empty_rep_storage);
+ return *reinterpret_cast<_Rep*>(__p);
+ }
bool
_M_is_leaked() const
OpenPOWER on IntegriCloud