It wouldn't be an immediate magic-blue-smoke situation, but I probably wouldn't connect all pins because:
- UART would be connected TX->TX and RX->RX which isn't useful
- The i2c pins would end up with two masters, which may or may not work depending on how skilfully you implement bus arbitration
- Bad things might happen if you set a pin on a Pi to output and the same pin on the other Pi to an input. The only thing limiting the current flow between those pins would be their impedance so it could brown out both Pi's at best.
Connecting a select few pins is a much more sensible approach, then you can design a communications bus that fits your needs and experiment with it safely. And unless you plan to do this anyway, there's really no benefit to connecting them directly since it would just complicate matters and lead to contention over the pins.
What would you be aiming to achieve?