http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46207

           Summary: std::atomic<const T *>::store(...) fails to compile
           Product: gcc
           Version: 4.6.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
        AssignedTo: unassig...@gcc.gnu.org
        ReportedBy: mi...@gnu.org


The following program:


#include <atomic>

std::atomic<int *> non_const_int_pointer;
void non_const_set (int *value)
{
  non_const_int_pointer.store (value, std::memory_order_release);
}

#ifndef SUPPRESS_CONST
std::atomic<const int *> const_int_pointer;
void const_set (const int *value)
{
  const_int_pointer.store (value, std::memory_order_release);
}
#endif


compiled with options "-O2 -march=native -std=c++0x", gives an error and fails
to compile because of the call to "const_int_pointer.store" (see error log
below).

However, the program compiles successfully if I add "-DSUPPRESS_CONST" to the
compiler options -- the call of "non_const_int_pointer.store" does not seem to
cause any problems.


Error log:

$ g++-snapshot --version
g++ (Debian 20101016-1) 4.6.0 20101016 (experimental) [trunk revision 165538]
Copyright (C) 2010 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

$ g++-snapshot -O2 -march=native -std=c++0x  -S al.cc
In file included from al.cc:1:0:
/usr/lib/gcc-snapshot/lib/gcc/x86_64-linux-gnu/4.6.0/../../../../include/c++/4.6.0/atomic:
In member function 'void std::atomic<_Tp*>::store(_Tp*, std::memory_order)
[with _Tp = const int, std::memory_order = std::memory_order]':
al.cc:13:60:   instantiated from here
/usr/lib/gcc-snapshot/lib/gcc/x86_64-linux-gnu/4.6.0/../../../../include/c++/4.6.0/atomic:145:9:
error: invalid conversion from 'const void*' to 'void*' [-fpermissive]
/usr/lib/gcc-snapshot/lib/gcc/x86_64-linux-gnu/4.6.0/../../../../include/c++/4.6.0/bits/atomic_2.h:99:5:
error:   initializing argument 1 of 'void
std::__atomic2::atomic_address::store(void*, std::memory_order)' [-fpermissive]

$ g++-snapshot -DSUPPRESS_CONST -O2 -march=native -std=c++0x  -S al.cc
$

Reply via email to