Quantcast
Channel: Intel® Fortran Compiler for Linux* and macOS*
Viewing all articles
Browse latest Browse all 2583

Compilation error #6866: Dotted string is neither a defined operator nor a structure component.

$
0
0

Hello,

First off, my compiler and some platform details:

$ ifort --version
ifort (IFORT) 16.0.1 20151021
Copyright (C) 1985-2015 Intel Corporation.  All rights reserved.

$ uname -a
Linux tfe04 2.6.32-431.29.2.el6.x86_64 #1 SMP Sun Jul 27 15:55:46 EDT 2014 x86_64 x86_64 x86_64 GNU/Linux

(It's a login node of a supercomputer)

I have an example of some code (shown below) that does not compile, exhibiting error #6866 which, based on my searches of these forums, should have been fixed in an earlier version.

MODULE my_define
  IMPLICIT NONE
  PRIVATE
  PUBLIC :: my_type

  TYPE :: my_type
    INTEGER :: j = 0
    INTEGER :: i = 0
  CONTAINS
    PRIVATE
    PROCEDURE :: Equal
    PROCEDURE :: NotEqual
    PROCEDURE :: Compare
    GENERIC, PUBLIC :: OPERATOR(==) => Equal
    GENERIC, PUBLIC :: OPERATOR(/=) => NotEqual
    GENERIC, PUBLIC :: OPERATOR(.Compare.) => Compare
  END TYPE my_type

CONTAINS

  ELEMENTAL FUNCTION Equal( x, y ) RESULT( is_equal )
    CLASS(my_type), INTENT(IN) :: x, y
    LOGICAL :: is_equal
    is_equal = (x%j == y%j) .AND. (x%i == y%i)
  END FUNCTION Equal


  ELEMENTAL FUNCTION NotEqual( x, y ) RESULT( not_equal )
    CLASS(my_type), INTENT(IN) :: x, y
    LOGICAL :: not_equal
    not_equal = .NOT. (x == y)
  END FUNCTION NotEqual


  FUNCTION Compare( x, y ) RESULT( is_equal )
    CLASS(my_type), INTENT(IN) :: x, y
    LOGICAL :: is_equal
    is_equal = .TRUE.
    IF ( x%j /= y%j ) THEN
      print *, 'J component of my objects are different'
      is_equal = .FALSE.
    END IF
    IF ( x%i /= y%i ) THEN
      print *, 'I component of my objects are different'
      is_equal = .FALSE.
    END IF
  END FUNCTION Compare

END MODULE my_define



! =======================
! Test program for module
! =======================

PROGRAM Test_my
  USE my_define, ONLY: my_type
  IMPLICIT NONE

  LOGICAL :: is_equal
  TYPE(my_type) :: my, my_copy

  my%j = 1
  my_copy = my
  IF ( my /= my_copy ) THEN
    is_equal = my .Compare. my_copy
  END IF
END PROGRAM Test_my

When I compile the above I get:

$ ifort one_type.f90
one_type.f90(67): error #6866: Dotted string is neither a defined operator nor a structure component.   [COMPARE]
    is_equal = my .Compare. my_copy
-------------------^
compilation aborted for one_type.f90 (code 1)

As far as I can tell, my test code is correct and standard conforming. Am I missing something?

The same code builds and runs fine using gfortran 4.9.x

Thanks for any information

cheers,

paulv

 


Viewing all articles
Browse latest Browse all 2583

Trending Articles