public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/46207] New: std::atomic<const T *>::store(...) fails to compile
@ 2010-10-28  5:35 miles at gnu dot org
  2010-10-28  9:32 ` [Bug libstdc++/46207] " paolo.carlini at oracle dot com
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: miles at gnu dot org @ 2010-10-28  5:35 UTC (permalink / raw)
  To: gcc-bugs

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: unassigned@gcc.gnu.org
        ReportedBy: miles@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
$


^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2011-02-17  1:50 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-10-28  5:35 [Bug libstdc++/46207] New: std::atomic<const T *>::store(...) fails to compile miles at gnu dot org
2010-10-28  9:32 ` [Bug libstdc++/46207] " paolo.carlini at oracle dot com
2010-10-28  9:50 ` paolo.carlini at oracle dot com
2010-10-28  9:54 ` redi at gcc dot gnu.org
2010-10-28  9:59 ` paolo.carlini at oracle dot com
2010-10-28 10:14 ` paolo.carlini at oracle dot com
2010-10-28 11:11 ` redi at gcc dot gnu.org
2010-10-29 11:09 ` paolo.carlini at oracle dot com
2010-10-29 22:57 ` bkoz at gcc dot gnu.org
2011-02-17  1:55 ` paolo.carlini at oracle dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).