http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58171

janus at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |janus at gcc dot gnu.org
            Summary|Incorrect error message on  |[F03] Incorrect error
                   |invalid code when using     |message on invalid code
                   |class constructor           |when using type constructor

--- Comment #1 from janus at gcc dot gnu.org ---
Well, I think in situations like this it is not trivial for the compiler to
guess what you want to do: In principle 'structure constructors' and
'constructor functions' (i.e. generic procedures with the same name as the
derived type) can be used alongside each other.

In your case: Since the call of 'cps' does not have the right number of
arguments to match the 'newCps' function, it is interpreted as a 'structure
constructor', but this also fails since your type has private components.

The compiler can not really tell whether you forgot one argument in the call,
or if you actually intended to call a structure constructor but 'wrongly' gave
the type private components.

Btw, if you rename the type, you will get the following:

Error: There is no specific function for the generic 'cps' at (1)

Does that sound more like what you were expecting?

If yes, one could think about adding a special error for cases like this (where
the type has private components and a 'constructor' function is present).

Reply via email to