I am trying to compile my code with clang, previously I used g ++.
I get errors compiling the following code:
#include <atomic>
typedef void (*my_func) ();
int main(int argc, char** argv)
{
std::atomic<my_func> _func;
_func();
return 0;
}
Mistake:
a.cpp:23:3: error: call to object of type 'std::atomic<my_func>' is ambiguous
_func();
^~~~~
/usr/bin/../lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8/atomic:304:7: note: conversion candidate of type 'void (*)()'
operator __pointer_type() const noexcept
^
/usr/bin/../lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8/atomic:307:7: note: conversion candidate of type 'void (*)()'
operator __pointer_type() const volatile noexcept
^
1 error generated.
This is not my code, this is legacy code that I need to use. In real code, _func is a member of the class and has a setter and getter, and as I understand it, it intends to protect it so that it does not change when it intends to call it.
Edit: I am using clang3.6 (same error for clang3.7) and g ++ and std :: atomic 4.8.
source
share