It is perfectly ok to do this. After all it does not matter whether two digitial pins (one input, one output) of different devices or the same device are connected to each other.
The one important thing is to consider that the maximum ratings of the GPIO pins are not exceeded - especially the current drawn from the pin. This holds true for any setup but more importantly so for configurable pins (GPIO pins that can be both input and output). As the state of the pin might change either during boot-up or accidentially due to bugged software the series resistor (as mentioned in joan's answer) is important to limit the current if both pins are set as outputs.