------- Comment #1 from janus at gcc dot gnu dot org 2010-08-26 17:54 ------- The dump shows that the first call to 'get_fmt' is executed dynamically as 'a.$vptr->get_fmt(...)', while the ones inside the SELECT TYPE block are resolved statically to 'd_base_get_fmt'. For the TYPE IS clause this is fine, but not so for CLASS DEFAULT, where a polymorphic call should be generated.
F08 quotes (chapter 8.1.9.2): Within the block following a TYPE IS type guard statement, the associating entity (16.5.5) is not polymorphic (4.3.1.3), has the type named in the type guard statement, and has the type parameter values of the selector. Within the block following a CLASS IS type guard statement, the associating entity is polymorphic and has the declared type named in the type guard statement. The type parameter values of the associating entity are the corresponding type parameter values of the selector. Within the block following a CLASS DEFAULT type guard statement, the associating entity is polymorphic and has the same declared type as the selector. The type parameter values of the associating entity are those of the declared type of the selector. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45420