Created
March 14, 2022 07:39
-
-
Save YukiSakamoto/24fb1a28bab036da39c18fb1d97ba77d to your computer and use it in GitHub Desktop.
The order of the arguments evaluation in C++
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <cstdio> | |
void func(int a, int b, int c) { | |
std::printf("%d %d %d\n", a, b, c); | |
} | |
int main(void) | |
{ | |
int i = 0; | |
func(i++, i++, i++); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
clang on Macの場合
関数の引数の左側から評価していく(ただし、fastcallしているのか、stackで引数を渡しているのかは不明)
gcc 4.8.5
引数をスタックに載せる順序を考慮するとこちらの方が自然かな
gcc 4.8.5 (O3オプション使用)
icc 19.0.5.281(gcc version 4.8.5 互換)