For Visual C++:
I finally managed to dig up the (well-hidden!) undocumented compiler flags that MSVC++ supports using information from here and here. Here they are:
/d1reportSingleClassLayoutXXX
/d1reportAllClassLayout
(replace XXX
with the class name)