We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
The code is as follow:
#include
template struct SimpleAllocator { template friend struct SimpleAllocator;
using value_type = T; using pointer = T *; struct rebind { template <typename U> using other = SimpleAllocator<U>; }; using propagate_on_container_copy_assignment = std::true_type; using propagate_on_container_move_assignment = std::true_type; using propagate_on_container_swap = std::true_type; explicit SimpleAllocator(void * p) : state(p) {} template <typename U> SimpleAllocator(SimpleAllocator<U> const & rhs) : state(rhs.state) {} pointer allocate(std::size_t n) { return static_cast<pointer>(::operator new(sizeof(T) * n)); } void deallocate(pointer p, std::size_t) { ::operator delete(p); } template <typename U, typename V> friend bool operator==(SimpleAllocator<U> const & lhs, SimpleAllocator<V> const & rhs) { return lhs.state == rhs.state; } template <typename U, typename V> friend bool operator!=(SimpleAllocator<U> const & lhs, SimpleAllocator<V> const & rhs) { return lhs.state != rhs.state; }
private: void * state; };
using astring = std::basic_string<char, std::char_traits, SimpleAllocator>;
int main() { int x, y;
SimpleAllocator<void> a(&x), b(&y); astring s("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", a); astring t(std::move(s), b);
}
The code sample comes from #20709 The latest clang compiles the attached code sample, but gcc produces many errors.
I reported the problem to gcc: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86074
In this discussion, programmers indicate that clang shall also reject the code. My report was marked as duplicated with multiple reports: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78925 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=54376
It said that GCC, EDG, and MSVC all reject the code, but clang++ accepts it.
Shall clang repair the problem?
The text was updated successfully, but these errors were encountered:
*** This bug has been marked as a duplicate of bug llvm/llvm-bugzilla-archive#31507 ***
Sorry, something went wrong.
No branches or pull requests
Extended Description
The code is as follow:
#include
template
struct SimpleAllocator
{
template friend struct SimpleAllocator;
private:
void * state;
};
using astring = std::basic_string<char, std::char_traits, SimpleAllocator>;
int main()
{
int x, y;
}
The code sample comes from #20709
The latest clang compiles the attached code sample, but gcc produces many errors.
I reported the problem to gcc: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86074
In this discussion, programmers indicate that clang shall also reject the code.
My report was marked as duplicated with multiple reports:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78925
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=54376
It said that GCC, EDG, and MSVC all reject the code, but clang++ accepts it.
Shall clang repair the problem?
The text was updated successfully, but these errors were encountered: