I'd be curious to know why it is illegal? The AIP states (for IFR flight) that terrain avoidance is the pilot's responsibility when departing on other than a SID or other procedure until least safe altitude is reached. Given I've been doing this for decades, I would very dearly like to know where it is illegal? Whether it is safe is of course open to debate (as for everything in aviation).