// C2011 (c) ISO/IEC JTC1 SC22 WG14 N1570
//6.5.2.4 Postfix increment and decrement operators
//c2011-6-5-2-4-ex.c
//(c) kaizen@gifu-u.ac.jp
//(c) Apple LLVM version 4.2 (clang-425.0.27) (based on LLVM 3.2svn)
//Target: x86_64-apple-darwin11.4.2
//Thread model: posix
// gcc-4.9 (GCC) 4.9.0 20131229 (experimental)
// Copyright (C) 2013 Free Software Foundation, Inc.
#include <stdio.h>
#include <stdatomic.h>

// note 98)

// bool atomic_compare_exchange_strong(volatile atomic<T>* object, T* expected, T desired) noexcept;
typedef int T;

int main(void){
T E;
T *addr = &E;
T old = *addr;
T new;
	
do {
new = old + 1;
} while (!atomic_compare_exchange_strong(addr, &old, new));
return printf("6.5.2.4 Postfix increment and decrement operators %d", new);
}
// LLVM 3.2 :c2011-6-5-2-4-ex.c:10:10: fatal error: 'atomic.h' file not found
//#include <stdatomic.h>
//         ^
//1 error generated.
//
// gcc output may be
// 6.5.2.4 Postfix increment and decrement operators 1
