This is the mail archive of the
mailing list for the GCC project.
std::aligned_storage and [[gnu::may_alias]]
- From: Avi Kivity <avi at scylladb dot com>
- To: gcc-help at gcc dot gnu dot org
- Date: Wed, 21 Jun 2017 00:20:03 +0300
- Subject: std::aligned_storage and [[gnu::may_alias]]
- Authentication-results: sourceware.org; auth=none
Does std::aligned_storage need a [[gnu::may_alias]] attribute?
it is not legal to cast a char array into another type (that is not a
relative of char*).
According to the example in
http://en.cppreference.com/w/cpp/types/aligned_storage, it's perfectly
all right to cast std::aligned_storage::data to some arbitrary T; and it
would be hard to find a use for aligned_storage without it.
std::function uses [[gnu::may_alias]] in a situation where
std::aligned_storage may be used.
Is this a problem in libstdc++, the standard, or my understanding of the
strict aliasing rules?