Skip to content

Instantly share code, notes, and snippets.

@usagi
Created December 10, 2013 01:26
Show Gist options
  • Select an option

  • Save usagi/7884339 to your computer and use it in GitHub Desktop.

Select an option

Save usagi/7884339 to your computer and use it in GitHub Desktop.
#include <iostream>
#include <typeinfo>
struct Hoge {
int a;
};
void f(Hoge& hoge);
void g() {
Hoge h = { -1 };
f(h);
std::cerr << typeid(h).name() << " " << sizeof(h)<< "\n";
}
#include <iostream>
#include <typeinfo>
struct Hoge {
int c;
int a;
};
void g();
void f(Hoge& hoge) {
std::cerr << typeid(hoge).name() << " " << sizeof(hoge) << "\n";
}
int main() {
Hoge h = { 0, 1 };
f(h);
g();
}
@usagi

usagi commented Dec 10, 2013

Copy link
Copy Markdown
Author

[result: compile & run]

uname -a
Linux LH-MAIN 3.8.0-34-generic #49-Ubuntu SMP Tue Nov 12 18:00:10 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux
{ clang++-3.2.1 | g++-4.7.3 } -O0 -g -o hoge -Wall -pedantic-errors hoge.cpp main.cpp
./hoge
4Hoge 8
4Hoge 8
4Hoge 8

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment