Gcc

From 탱이의 잡동사니
Jump to navigation Jump to search
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

Overview

GNU c/c++ 컴파일러 gcc 내용 정리

Function parameter evaluation order

gcc 뿐만이 아니라, 모든 c 에 해당되는 내용이다.

간단히 말해서, function parameter 로 전달되는 parameter 들의 evaluation 에는 순서가 없다. 즉, 어떤 순위로 식이 평가되는지 알 수 없다는 것이다<ref>http://stackoverflow.com/a/621548/713079</ref>.

It depends on the argument type, the called function's calling convention, the archtecture and the compiler

재밌는 테스트 결과가 있었다. 다음의 예제를 보면 이해가 쉬울 것이다.

int i=1;
printf("%d %d %d\n", i++, i++, i);

results in

2 1 3 - using g++ 4.2.1 on Linux.i686
1 2 3 - using SunStudio C++ 5.9 on Linux.i686
2 1 3 - using g++ 4.2.1 on SunOS.x86pc
1 2 3 - using SunStudio C++ 5.9 on SunOS.x86pc
1 2 3 - using g++ 4.2.1 on SunOS.sun4u
1 2 3 - using SunStudio C++ 5.9 on SunOS.sun4u

Options

See also

Reference

<references />