public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/67779] New: Strange ordering with strings in extended object
@ 2015-09-30 10:58 arjen.markus895 at gmail dot com
  2015-10-01 18:46 ` [Bug fortran/67779] " gerhard.steinmetz.fortran@t-online.de
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: arjen.markus895 at gmail dot com @ 2015-09-30 10:58 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67779

            Bug ID: 67779
           Summary: Strange ordering with strings in extended object
           Product: gcc
           Version: 4.9.3
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: arjen.markus895 at gmail dot com
  Target Milestone: ---

Created attachment 36421
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=36421&action=edit
Source file demonstrating the problem

The attached program constructs a small array of integers and strings and then
sorts them. The output is:
 Sorting ...
 Result:
           1
           2
           3
           4
           5
           6
           7
           8
           9
          10
 String = 10         
 String = 1          
 String = 2          
 String = 3          
 String = 4          
 String = 5          
 String = 6          
 String = 7          
 String = 8          
 String = 9           

What is unexpected is the fact that "String = 10" comes before "String = 1". I
have not been able to reduce the code (other than removing the derived type
with integers) and still exhibit the odd ordering. The ten integers show that
the quicksort routine does its job, though. When comparing the strings in a
small program, "String = 10" definitely comes after "String = 1" as I would
expect.


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

* [Bug fortran/67779] Strange ordering with strings in extended object
  2015-09-30 10:58 [Bug fortran/67779] New: Strange ordering with strings in extended object arjen.markus895 at gmail dot com
@ 2015-10-01 18:46 ` gerhard.steinmetz.fortran@t-online.de
  2015-10-09 13:46 ` dominiq at lps dot ens.fr
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: gerhard.steinmetz.fortran@t-online.de @ 2015-10-01 18:46 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67779

Gerhard Steinmetz <gerhard.steinmetz.fortran@t-online.de> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |gerhard.steinmetz.fortran@t
                   |                            |-online.de

--- Comment #1 from Gerhard Steinmetz <gerhard.steinmetz.fortran@t-online.de> ---
This differs :
   llt('9 ', '10') : F
   llt(' 9', '10') : T

Test : changing format '(a,i0)' to e.g. '(a,i2)'

$ a.out
 Sorting ...
 Result:
           1
           2
           3
           4
           5
           6
           7
           8
           9
          10
 String =  1
 String =  2
 String =  3
 String =  4
 String =  5
 String =  6
 String =  7
 String =  8
 String =  9
 String = 10


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

* [Bug fortran/67779] Strange ordering with strings in extended object
  2015-09-30 10:58 [Bug fortran/67779] New: Strange ordering with strings in extended object arjen.markus895 at gmail dot com
  2015-10-01 18:46 ` [Bug fortran/67779] " gerhard.steinmetz.fortran@t-online.de
@ 2015-10-09 13:46 ` dominiq at lps dot ens.fr
  2015-10-09 13:56 ` arjen.markus895 at gmail dot com
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: dominiq at lps dot ens.fr @ 2015-10-09 13:46 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67779

Dominique d'Humieres <dominiq at lps dot ens.fr> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |WAITING
   Last reconfirmed|                            |2015-10-09
     Ever confirmed|0                           |1

--- Comment #2 from Dominique d'Humieres <dominiq at lps dot ens.fr> ---
> Test : changing format '(a,i0)' to e.g. '(a,i2)'

Confirmed. Closing as INVALID?


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

* [Bug fortran/67779] Strange ordering with strings in extended object
  2015-09-30 10:58 [Bug fortran/67779] New: Strange ordering with strings in extended object arjen.markus895 at gmail dot com
  2015-10-01 18:46 ` [Bug fortran/67779] " gerhard.steinmetz.fortran@t-online.de
  2015-10-09 13:46 ` dominiq at lps dot ens.fr
@ 2015-10-09 13:56 ` arjen.markus895 at gmail dot com
  2015-10-09 16:04 ` dominiq at lps dot ens.fr
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: arjen.markus895 at gmail dot com @ 2015-10-09 13:56 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67779

--- Comment #3 from Arjen Markus <arjen.markus895 at gmail dot com> ---
Let me clarify: 
the STRING "String = 10" should come after the STRING "String = 1 ". It is not
a matter of the numbers inside. If you compare these strings with LLT(), you
will see this.


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

* [Bug fortran/67779] Strange ordering with strings in extended object
  2015-09-30 10:58 [Bug fortran/67779] New: Strange ordering with strings in extended object arjen.markus895 at gmail dot com
                   ` (2 preceding siblings ...)
  2015-10-09 13:56 ` arjen.markus895 at gmail dot com
@ 2015-10-09 16:04 ` dominiq at lps dot ens.fr
  2015-10-10  8:08 ` dominiq at lps dot ens.fr
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: dominiq at lps dot ens.fr @ 2015-10-09 16:04 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67779

--- Comment #4 from Dominique d'Humieres <dominiq at lps dot ens.fr> ---
I have instrumented the test and found that 'String = 10         ', which at
the first position, is compared only once at the first call to quick sort, but
not for the other invocations of array(1:j). I am unable to understand why.


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

* [Bug fortran/67779] Strange ordering with strings in extended object
  2015-09-30 10:58 [Bug fortran/67779] New: Strange ordering with strings in extended object arjen.markus895 at gmail dot com
                   ` (3 preceding siblings ...)
  2015-10-09 16:04 ` dominiq at lps dot ens.fr
@ 2015-10-10  8:08 ` dominiq at lps dot ens.fr
  2015-10-11  9:05 ` dominiq at lps dot ens.fr
  2015-10-12  9:53 ` arjen.markus895 at gmail dot com
  6 siblings, 0 replies; 8+ messages in thread
From: dominiq at lps dot ens.fr @ 2015-10-10  8:08 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67779

--- Comment #5 from Dominique d'Humieres <dominiq at lps dot ens.fr> ---
Apparently there is a nasty bug somewhere: if I sort

           'String = 2          '
           'String = 9          '
           'String = 8          '
           'String = 7          '
           'String = 6          '
           'String = 5          '
           'String = 4          '
           'String = 3          '
           'String = 10         '
           'String = 1          '

I get

 String = 2          
 String = 1          
 String = 10         
 String = 3          
 String = 4          
 String = 5          
 String = 6          
 String = 7          
 String = 8          
 String = 9


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

* [Bug fortran/67779] Strange ordering with strings in extended object
  2015-09-30 10:58 [Bug fortran/67779] New: Strange ordering with strings in extended object arjen.markus895 at gmail dot com
                   ` (4 preceding siblings ...)
  2015-10-10  8:08 ` dominiq at lps dot ens.fr
@ 2015-10-11  9:05 ` dominiq at lps dot ens.fr
  2015-10-12  9:53 ` arjen.markus895 at gmail dot com
  6 siblings, 0 replies; 8+ messages in thread
From: dominiq at lps dot ens.fr @ 2015-10-11  9:05 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67779

--- Comment #6 from Dominique d'Humieres <dominiq at lps dot ens.fr> ---
The problem is not limited to strings. If I add the following lines

        array(1)%value = 2
        array(9)%value = 10
        write( string_array(1)%value, '(a,i0)' ) "String = ", 2
        write( string_array(9)%value, '(a,i0)' ) "String = ", 10

the initial values are

           2 'String = 2          '
           9 'String = 9          '
           8 'String = 8          '
           7 'String = 7          '
           6 'String = 6          '
           5 'String = 5          '
           4 'String = 4          '
           3 'String = 3          '
          10 'String = 10         '
           1 'String = 1          '

and the "sorted" ones are

           2
           1
           3
           4
           5
           6
           7
           8
          10
           9
 String = 2          
 String = 1          
 String = 10         
 String = 3          
 String = 4          
 String = 5          
 String = 6          
 String = 7          
 String = 8          
 String = 9


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

* [Bug fortran/67779] Strange ordering with strings in extended object
  2015-09-30 10:58 [Bug fortran/67779] New: Strange ordering with strings in extended object arjen.markus895 at gmail dot com
                   ` (5 preceding siblings ...)
  2015-10-11  9:05 ` dominiq at lps dot ens.fr
@ 2015-10-12  9:53 ` arjen.markus895 at gmail dot com
  6 siblings, 0 replies; 8+ messages in thread
From: arjen.markus895 at gmail dot com @ 2015-10-12  9:53 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67779

--- Comment #7 from Arjen Markus <arjen.markus895 at gmail dot com> ---
Yes, I can confirm this - I also tried with the Intel Fortran compiler and that
sorts the integers and strings in the way one would expect.


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

end of thread, other threads:[~2015-10-12  9:53 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-09-30 10:58 [Bug fortran/67779] New: Strange ordering with strings in extended object arjen.markus895 at gmail dot com
2015-10-01 18:46 ` [Bug fortran/67779] " gerhard.steinmetz.fortran@t-online.de
2015-10-09 13:46 ` dominiq at lps dot ens.fr
2015-10-09 13:56 ` arjen.markus895 at gmail dot com
2015-10-09 16:04 ` dominiq at lps dot ens.fr
2015-10-10  8:08 ` dominiq at lps dot ens.fr
2015-10-11  9:05 ` dominiq at lps dot ens.fr
2015-10-12  9:53 ` arjen.markus895 at gmail dot com

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).