Interesting, even this can't fool the optimizer (tried with a recent gcc and clang):
unsigned add(unsigned x, unsigned y) { std::vector vx {x}; std::vector vy {y}; auto res = vx[0]+vy[0]; return res; }