While I cannot comment on thespecific codes, whether Inspectors notice or report violations or not depends on their skill levels, work experience, and the contracts. Some contractors may not enter attic or crawlspace if deemed dangerous, even if only a minor possibility of getting scrapes might be present. Some may not get on top of the roof either, further increasing a chance of overlooking defects or code violations. These should be found be in the contract you sign with them. While many inspectors strive for excellence, some do less than adequate job. Your inspector, if the attic was easily accessible, probably should have noticed it but It's not illegal to have missed something, since it's very difficult to find "everything". The contract should include a clause about the legal extent of inspectors and how to proceed with a damage claim for the defects (which may or may not be a code violation) found after the purchsse, which the contract might or might state whether the inspector should have discovered it.