Internationally, (the UK is a special case), if you are on a SID or a STAR you comply with those restrictions/requirements unless the SID or STAR is specifically cancelled (unless the RT is specific... ie cancel SID altitude/speed restrictions).
Any other instruction is to be complied with in accordance with the SID/STAR.