public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libfortran/27401]  New: Bad overloaded operator selected
@ 2006-05-02 19:51 ajdiaz at connectical dot net
  2006-05-02 21:00 ` [Bug libfortran/27401] " pinskia at gcc dot gnu dot org
  2006-05-05 11:12 ` fxcoudert at gcc dot gnu dot org
  0 siblings, 2 replies; 3+ messages in thread
From: ajdiaz at connectical dot net @ 2006-05-02 19:51 UTC (permalink / raw)
  To: gcc-bugs

I think I found a bug related to operator overloading in gfortran-4.1.0 (as
you can see below gfortran-4.2.0 doesn't seem to have the problem).

The problem arises when trying to perform an operation which takes
a multidimensional array and two operators are defined:

    - One with two multidimensional arguments.
    - Another with a single unidimensional argument and another
      multimensional argument.

One would expect the first one being applied when both arguments have more
than one dimension, but version 4.1.0 keeps using the second operator.

A small example is attached below, as well as compiler output for both 4.1
and 4.2 versions of the compiler.

This bug is reproducible also in powerpc-unknown-linux-gnu box.

Compiling command:
------------------

<ajdiaz@shannon> [~/bug]$ gfortran -v -save-temps -o bugs bug.f90 
Driving: gfortran -v -save-temps -o bugs bug.f90 -lgfortranbegin -lgfortran -lm
-shared-libgcc
Using built-in specs.
Target: i686-pc-linux-gnu
Configured with: /var/tmp/portage/gcc-4.1.0/work/gcc-4.1.0/configure
--prefix=/usr --bindir=/usr/i686-pc-linux-gnu/gcc-bin/4.1.0
--includedir=/usr/lib/gcc/i686-pc-linux-gnu/4.1.0/include
--datadir=/usr/share/gcc-data/i686-pc-linux-gnu/4.1.0
--mandir=/usr/share/gcc-data/i686-pc-linux-gnu/4.1.0/man
--infodir=/usr/share/gcc-data/i686-pc-linux-gnu/4.1.0/info
--with-gxx-include-dir=/usr/lib/gcc/i686-pc-linux-gnu/4.1.0/include/g++-v4
--host=i686-pc-linux-gnu --build=i686-pc-linux-gnu --disable-altivec
--disable-nls --with-system-zlib --disable-checking --disable-werror
--disable-libunwind-exceptions --disable-multilib --disable-libmudflap
--disable-libssp --disable-libgcj --enable-languages=c,c++,fortran
--enable-shared --enable-threads=posix --enable-__cxa_atexit
--enable-clocale=gnu
Thread model: posix
gcc version 4.1.0 (Gentoo 4.1.0)
 /usr/libexec/gcc/i686-pc-linux-gnu/4.1.0/f951 bug.f90 -quiet -dumpbase bug.f90
-mtune=pentiumpro -auxbase bug -version -o bug.s
GNU F95 version 4.1.0 (Gentoo 4.1.0) (i686-pc-linux-gnu)
        compiled by GNU C version 4.1.0 (Gentoo 4.1.0).
GGC heuristics: --param ggc-min-expand=63 --param ggc-min-heapsize=62387
 /usr/lib/gcc/i686-pc-linux-gnu/4.1.0/../../../../i686-pc-linux-gnu/bin/as -V
-Qy -o bug.o bug.s
GNU assembler version 2.16.1 (i686-pc-linux-gnu) using BFD version 2.16.1
 /usr/libexec/gcc/i686-pc-linux-gnu/4.1.0/collect2 --eh-frame-hdr -m elf_i386
-dynamic-linker /lib/ld-linux.so.2 -o bugs
/usr/lib/gcc/i686-pc-linux-gnu/4.1.0/../../../crt1.o
/usr/lib/gcc/i686-pc-linux-gnu/4.1.0/../../../crti.o
/usr/lib/gcc/i686-pc-linux-gnu/4.1.0/crtbegin.o
-L/usr/lib/gcc/i686-pc-linux-gnu/4.1.0 -L/usr/lib/gcc/i686-pc-linux-gnu/4.1.0
-L/usr/lib/gcc/i686-pc-linux-gnu/4.1.0/../../../../i686-pc-linux-gnu/lib
-L/usr/lib/gcc/i686-pc-linux-gnu/4.1.0/../../.. bug.o -lgfortranbegin
-lgfortran -lm -lgcc_s -lgcc -lc -lgcc_s -lgcc
/usr/lib/gcc/i686-pc-linux-gnu/4.1.0/crtend.o
/usr/lib/gcc/i686-pc-linux-gnu/4.1.0/../../../crtn.o

Execution command:
------------------

<ajdiaz@shannon> [~/bug]$ ./bugs 
 Stinks! I do not want this!
           1           1

The code runs over the non-two dimensional argument function.

Source code
-----------

module bug_mod

    implicit none

    type foo
        integer :: bar
    end type foo

    interface operator (+)
        module procedure fun, sux
    end interface


    contains

        function fun ( x, y ) result (z)
            type(foo), intent(in), dimension(:,:) :: x
            type(foo), intent(in), dimension(size(x,1),size(x,2)):: y
            type(foo),             dimension(size(x,1),size(x,2)):: z;

            print*,'I want to run this function'
            z%bar = 0
        end function fun

        function sux( x, y ) result (z)
            type(foo), intent(in), dimension(:,:)       :: x
            type(foo), intent(in), dimension(size(x,1)) :: y
            type(foo),             dimension(size(x,1)) :: z

            print*,'Stinks! I do not want this!'
            z%bar = 1
        end function sux


end module bug_mod

program bug

    use bug_mod
    implicit none

    type(foo), dimension(2,2) :: a,c

    a%bar = 0
    c%bar = 0

    print*, (a + c) ! I would expect dim(2) + dim(2) => fun

end program bug


-- 
           Summary: Bad overloaded operator selected
           Product: gcc
           Version: 4.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libfortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: ajdiaz at connectical dot net
 GCC build triplet: i686-pc-linux-gnu
  GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu


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


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug libfortran/27401] Bad overloaded operator selected
  2006-05-02 19:51 [Bug libfortran/27401] New: Bad overloaded operator selected ajdiaz at connectical dot net
@ 2006-05-02 21:00 ` pinskia at gcc dot gnu dot org
  2006-05-05 11:12 ` fxcoudert at gcc dot gnu dot org
  1 sibling, 0 replies; 3+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2006-05-02 21:00 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from pinskia at gcc dot gnu dot org  2006-05-02 21:00 -------
I bet $100 this is already fixed in SVN for 4.1.1.


-- 


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


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug libfortran/27401] Bad overloaded operator selected
  2006-05-02 19:51 [Bug libfortran/27401] New: Bad overloaded operator selected ajdiaz at connectical dot net
  2006-05-02 21:00 ` [Bug libfortran/27401] " pinskia at gcc dot gnu dot org
@ 2006-05-05 11:12 ` fxcoudert at gcc dot gnu dot org
  1 sibling, 0 replies; 3+ messages in thread
From: fxcoudert at gcc dot gnu dot org @ 2006-05-05 11:12 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from fxcoudert at gcc dot gnu dot org  2006-05-05 11:12 -------
This is indeed fixed on 4.1 branch, that should be (soon?) released as 4.1.1.
This was previously reported as bug #26716.

*** This bug has been marked as a duplicate of 26716 ***


-- 

fxcoudert at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |DUPLICATE


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


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2006-05-05 11:12 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-05-02 19:51 [Bug libfortran/27401] New: Bad overloaded operator selected ajdiaz at connectical dot net
2006-05-02 21:00 ` [Bug libfortran/27401] " pinskia at gcc dot gnu dot org
2006-05-05 11:12 ` fxcoudert at gcc dot gnu dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).