tl;dr: The question is for an explanation for why std::stringstream
\"fails\", and why it fails in the way it does (by simply doing nothing), when
Please try this:
LOCAL_LDFLAGS += -Wl,--gc-sections
It seems that the code snippet doesn't really called atomic_fetch_add(). With --gc-sections LD option, the linker will eliminate the unused code and data from the final executable or shared library. So that the dependency of atomic_fetch_add() is likely to be removed.
Description of "--gc-sections": https://gcc.gnu.org/onlinedocs/gnat_ugn/Compilation-options.html
Some other infomation: https://code.google.com/p/android/issues/detail?id=68779