Bug 22423 - Warnings when building libgfortran
Summary: Warnings when building libgfortran
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: libfortran (show other bugs)
Version: 4.5.0
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
: 40545 (view as bug list)
Depends on: 26540
Blocks:
  Show dependency treegraph
 
Reported: 2005-07-12 02:37 UTC by fengwang
Modified: 2009-07-13 06:31 UTC (History)
8 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2009-07-05 09:24:41


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description fengwang 2005-07-12 02:37:24 UTC
There are warnings when build libgfortran:

$grep warning buildlog
[snip]
../../../gcc/libgfortran/generated/matmul_i4.c:102: warning: passing argument 1
../../../gcc/libgfortran/generated/matmul_i4.c:185: warning: passing argument 1
../../../gcc/libgfortran/generated/matmul_i4.c:185: warning: passing argument 1
../../../gcc/libgfortran/generated/matmul_i4.c:185: warning: passing argument 1
../../../gcc/libgfortran/generated/matmul_i4.c:185: warning: passing argument 1
../../../gcc/libgfortran/generated/matmul_i4.c:185: warning: passing argument 1
../../../gcc/libgfortran/generated/matmul_i4.c:185: warning: passing argument 1
../../../gcc/libgfortran/generated/matmul_i8.c:102: warning: passing argument 1
../../../gcc/libgfortran/generated/matmul_i8.c:185: warning: passing argument 1
../../../gcc/libgfortran/generated/matmul_i8.c:185: warning: passing argument 1
../../../gcc/libgfortran/generated/matmul_i8.c:185: warning: passing argument 1
../../../gcc/libgfortran/generated/matmul_i8.c:185: warning: passing argument 1
../../../gcc/libgfortran/generated/matmul_i8.c:185: warning: passing argument 1
../../../gcc/libgfortran/generated/matmul_i8.c:185: warning: passing argument 1
../../../gcc/libgfortran/generated/matmul_r4.c:102: warning: passing argument 1
../../../gcc/libgfortran/generated/matmul_r4.c:185: warning: passing argument 1
../../../gcc/libgfortran/generated/matmul_r4.c:185: warning: passing argument 1
../../../gcc/libgfortran/generated/matmul_r4.c:185: warning: passing argument 1
../../../gcc/libgfortran/generated/matmul_r4.c:185: warning: passing argument 1
../../../gcc/libgfortran/generated/matmul_r4.c:185: warning: passing argument 1
../../../gcc/libgfortran/generated/matmul_r4.c:185: warning: passing argument 1
../../../gcc/libgfortran/generated/matmul_r8.c:102: warning: passing argument 1
../../../gcc/libgfortran/generated/matmul_r8.c:185: warning: passing argument 1
../../../gcc/libgfortran/generated/matmul_r8.c:185: warning: passing argument 1
../../../gcc/libgfortran/generated/matmul_r8.c:185: warning: passing argument 1
../../../gcc/libgfortran/generated/matmul_r8.c:185: warning: passing argument 1
../../../gcc/libgfortran/generated/matmul_r8.c:185: warning: passing argument 1
../../../gcc/libgfortran/generated/matmul_r8.c:185: warning: passing argument 1
../../../gcc/libgfortran/generated/matmul_c4.c:102: warning: passing argument 1
../../../gcc/libgfortran/generated/matmul_c4.c:185: warning: passing argument 1
../../../gcc/libgfortran/generated/matmul_c4.c:185: warning: passing argument 1
../../../gcc/libgfortran/generated/matmul_c4.c:185: warning: passing argument 1
../../../gcc/libgfortran/generated/matmul_c4.c:185: warning: passing argument 1
../../../gcc/libgfortran/generated/matmul_c4.c:185: warning: passing argument 1
../../../gcc/libgfortran/generated/matmul_c4.c:185: warning: passing argument 1
../../../gcc/libgfortran/generated/matmul_c8.c:102: warning: passing argument 1
../../../gcc/libgfortran/generated/matmul_c8.c:185: warning: passing argument 1
../../../gcc/libgfortran/generated/matmul_c8.c:185: warning: passing argument 1
../../../gcc/libgfortran/generated/matmul_c8.c:185: warning: passing argument 1
../../../gcc/libgfortran/generated/matmul_c8.c:185: warning: passing argument 1
../../../gcc/libgfortran/generated/matmul_c8.c:185: warning: passing argument 1
../../../gcc/libgfortran/generated/matmul_c8.c:185: warning: passing argument 1
../../../gcc/libgfortran/generated/transpose_i4.c:66: warning: passing argument
../../../gcc/libgfortran/generated/transpose_i8.c:66: warning: passing argument
../../../gcc/libgfortran/generated/transpose_c4.c:66: warning: passing argument
../../../gcc/libgfortran/generated/transpose_c8.c:66: warning: passing argument
../../../gcc/libgfortran/generated/eoshift1_4.c:61: warning: 'soffset' may be 
us
../../../gcc/libgfortran/generated/eoshift1_4.c:73: warning: 'len' may be used 
u
../../../gcc/libgfortran/generated/eoshift1_4.c:55: warning: 'roffset' may be 
us
../../../gcc/libgfortran/generated/eoshift1_8.c:61: warning: 'soffset' may be 
us
../../../gcc/libgfortran/generated/eoshift1_8.c:73: warning: 'len' may be used 
u
../../../gcc/libgfortran/generated/eoshift1_8.c:55: warning: 'roffset' may be 
us
../../../gcc/libgfortran/generated/eoshift3_4.c:75: warning: 'len' may be used 
u
../../../gcc/libgfortran/generated/eoshift3_4.c:59: warning: 'soffset' may be 
us
../../../gcc/libgfortran/generated/eoshift3_4.c:53: warning: 'roffset' may be 
us
../../../gcc/libgfortran/generated/eoshift3_8.c:75: warning: 'len' may be used 
u
../../../gcc/libgfortran/generated/eoshift3_8.c:59: warning: 'soffset' may be 
us
../../../gcc/libgfortran/generated/eoshift3_8.c:53: warning: 'roffset' may be 
us
../../../gcc/libgfortran/io/list_read.c:2187: warning: missing braces around 
ini
../../../gcc/libgfortran/io/list_read.c:2187: warning: (near initialization for
../../../gcc/libgfortran/io/list_read.c:2188: warning: missing braces around 
ini
../../../gcc/libgfortran/io/list_read.c:2188: warning: (near initialization for
../../../gcc/libgfortran/io/list_read.c:2025: warning: 'first_nl' may be used 
un
../../../gcc/libgfortran/io/list_read.c:2026: warning: 'root_nl' may be used 
uni
../../../gcc/libgfortran/intrinsics/eoshift0.c:50: warning: 'roffset' may be 
use
../../../gcc/libgfortran/intrinsics/eoshift0.c:64: warning: 'len' may be used 
un
../../../gcc/libgfortran/intrinsics/eoshift0.c:56: warning: 'soffset' may be 
use
../../../gcc/libgfortran/intrinsics/eoshift2.c:68: warning: 'len' may be used 
un
../../../gcc/libgfortran/intrinsics/eoshift2.c:56: warning: 'soffset' may be 
use
../../../gcc/libgfortran/intrinsics/eoshift2.c:50: warning: 'roffset' may be 
use
../../../gcc/libgfortran/intrinsics/spread_generic.c:48: warning: 'rdelta' may 
b
../../../gcc/libgfortran/intrinsics/rename.c:61: warning: implicit declaration 
o
../../../gcc/libgfortran/intrinsics/rename.c:61: warning: incompatible implicit
../../../gcc/libgfortran/intrinsics/rename.c:68: warning: implicit declaration 
o
../../../gcc/libgfortran/intrinsics/rename.c:94: warning: incompatible implicit
../../../gcc/libgfortran/intrinsics/unpack_generic.c:194: warning: passing 
argum
[snip]
Comment 1 Francois-Xavier Coudert 2005-09-24 13:14:40 UTC
The list of warnings is not that long any more:

../../../gcc/libgfortran/io/list_read.c: In function 'list_formatted_read':
../../../gcc/libgfortran/io/list_read.c:1289: warning: argument 'len' might be
clobbered by 'longjmp' or 'vfork'

../../../gcc/libgfortran/io/read.c: In function 'read_f':
../../../gcc/libgfortran/io/read.c:624: warning: value computed is not used

../../../gcc/libgfortran/io/unit.c: In function 'get_array_unit_len':
../../../gcc/libgfortran/io/unit.c:264: warning: return makes integer from
pointer without a cast

There are also warnings due to PR 18452:
cc1: warning: command line option "-fno-repack-arrays" is valid for Fortran but
not for C
Comment 2 Andrew Pinski 2005-10-02 18:00:58 UTC
(In reply to comment #1)
> 
> ../../../gcc/libgfortran/io/read.c: In function 'read_f':
> ../../../gcc/libgfortran/io/read.c:624: warning: value computed is not used
> 
> ../../../gcc/libgfortran/io/unit.c: In function 'get_array_unit_len':
> ../../../gcc/libgfortran/io/unit.c:264: warning: return makes integer from
> pointer without a cast

Those two were fixed by:

        * io/unit.c (get_array_unit_len): Return 0 rather than NULL.

        * io/read.c (read_f): Remove spurious pointer dereference.
Comment 3 Francois-Xavier Coudert 2006-05-19 17:04:21 UTC
We currently have the following warnings when building libgfortran on i686-linux:

../../../gcc/libgfortran/io/transfer.c: In function 'read_block':
../../../gcc/libgfortran/io/transfer.c:279: warning: 'return' with no value, in function returning non-void
../../../gcc/libgfortran/io/transfer.c:309: warning: this function may return with or without a value

../../../gcc/libgfortran/io/list_read.c: In function 'list_formatted_read_scalar':
../../../gcc/libgfortran/io/list_read.c:1460: warning: argument 'type' might be clobbered by 'longjmp' or 'vfork'

There are also some related to signal when compiling on LP64: that's PR 26540.
Comment 4 Francois-Xavier Coudert 2006-05-19 17:05:49 UTC
Adding Jerry in CC list since he's likely to be the one who introduced the warning in transfer.c :)
Comment 5 Jerry DeLisle 2006-05-20 02:56:08 UTC
I will fix the one in transfer.c as obvious.

I don't understand the issue in list_read.c  I have a namelist patch pending for that file so if someone could give me a hint I would be happy to fix that as well.
Comment 6 Jerry DeLisle 2006-05-20 03:30:31 UTC
Subject: Bug 22423

Author: jvdelisle
Date: Sat May 20 03:29:58 2006
New Revision: 113923

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=113923
Log:
2006-05-19  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	PR libgfortran/22423
	* io/transfer.c (read_block): Return NULL instead of nothing.

Modified:
    trunk/libgfortran/ChangeLog
    trunk/libgfortran/io/transfer.c

Comment 7 Francois-Xavier Coudert 2006-10-01 07:43:53 UTC
Apart from the warnings in PR 26540, the situation is stable with the only warning being:

../../../trunk/libgfortran/io/list_read.c: In function ‘list_formatted_read_scalar’:
../../../trunk/libgfortran/io/list_read.c:1460: warning: argument ‘type’ might be clobbered by ‘longjmp’ or ‘vfork’

I think this warning is not worth the trouble of rewriting this critical part of the code, potentially introducing a nasty regression or something like that.
Comment 8 Jack Howarth 2006-10-01 16:38:24 UTC
FX,
    I found a thread that discusses a simple fix...

http://curl.haxx.se/mail/lib-2004-10/0089.html

All we have to change is...

Index: io/list_read.c
===================================================================
--- io/list_read.c      (revision 117347)
+++ io/list_read.c      (working copy)
@@ -1457,7 +1457,7 @@ check_type (st_parameter_dt *dtp, bt typ
    greater than one, we copy the data item multiple times.  */
 
 static void
-list_formatted_read_scalar (st_parameter_dt *dtp, bt type, void *p, int kind,
+list_formatted_read_scalar (st_parameter_dt *dtp, volatile bt type, void *p, int kind,
                            size_t size)
 {
   char c;

...to keep type out of a register and the warning goes away! Can you test that change 
on your system?
Comment 9 Francois-Xavier Coudert 2007-01-18 17:45:32 UTC
Once that last warning is fixed, I'd really like libgfortran to be built with -Werror by default, at least on linux systems (it's known to issue tons of warnings on some non-C99 systems, so we can't make it the default unconditionaly).
Comment 10 Jack Howarth 2007-01-18 19:18:25 UTC
FX,
   So are you going to use the fix I proposed in comment 8? Do you want me to submit it to the patch mailing list first?
Comment 11 Francois-Xavier Coudert 2007-01-18 19:32:44 UTC
(In reply to comment #10)
>    So are you going to use the fix I proposed in comment 8?

Yes.

> Do you want me to
> submit it to the patch mailing list first?

No, it's been posted a few times already, and I've also discussed it on IRC a few times with other people, so it can be considered approved (or, to have someone accountable in case of trouble: I approve it :)

I'll commit it when I get to it (over the week-end?) Anyone feel free to do it (after bootstrap and regesteing) if you don't see it commited in the next few days.
Comment 12 Francois-Xavier Coudert 2007-03-04 08:32:29 UTC
Jerry sent me (on 2007-01-19) the following mail:

"Andrew Pinski had issues with this fix because it is covering up a problem somewhere else.  He said on IRC he may have time to look into this and get a correct fix tonight.  We had quite a bit of discussion some time back on this issue.  I suggest you hold off a bit."

Since I've had no news since, Andrew, did you have time to give it a look?
Comment 13 Tobias Schlüter 2007-10-07 21:48:47 UTC
The current set of warnings is:

../../../libgfortran/runtime/backtrace.c:66: warning: 'local_strcasestr' defined but not used
../../../libgfortran/runtime/environ.c:312: warning: 'init_choice' defined but not used
../../../libgfortran/runtime/environ.c:339: warning: 'show_choice' defined but not used
../../../libgfortran/runtime/main.c:179: warning: passing argument 1 of 'free' discards qualifiers from pointer target type
../../../libgfortran/io/list_read.c:1518: warning: argument 'type' might be clobbered by 'longjmp' or 'vfork'
../../../libgfortran/intrinsics/pack_generic.c:316: warning: passing argument 3 of 'pack_internal' from incompatible pointer type
../../../libgfortran/intrinsics/pack_generic.c:331: warning: passing argument 3 of 'pack_internal' from incompatible pointer type
../../../libgfortran/intrinsics/spread_generic.c:136: warning: format '%d' expects type 'int', but argument 2 has type 'long int'
../../../libgfortran/intrinsics/spread_generic.c:147: warning: format '%d' expects type 'int', but argument 2 has type 'long int'
../../../libgfortran/intrinsics/unpack_generic.c:201: warning: passing argument 3 of 'unpack_internal' from incompatible pointer type
../../../libgfortran/intrinsics/unpack_generic.c:217: warning: passing argument 3 of 'unpack_internal' from incompatible pointer type
../../../libgfortran/intrinsics/unpack_generic.c:233: warning: passing argument 3 of 'unpack_internal' from incompatible pointer type
../../../libgfortran/intrinsics/unpack_generic.c:253: warning: passing argument 3 of 'unpack_internal' from incompatible pointer type
../../../../libgfortran/runtime/backtrace.c:66: warning: 'local_strcasestr' defined but not used
../../../../libgfortran/runtime/environ.c:312: warning: 'init_choice' defined but not used
../../../../libgfortran/runtime/environ.c:339: warning: 'show_choice' defined but not used
../../../../libgfortran/runtime/main.c:179: warning: passing argument 1 of 'free' discards qualifiers from pointer target type
../../../../libgfortran/io/list_read.c:1518: warning: argument 'type' might be clobbered by 'longjmp' or 'vfork'
../../../../libgfortran/intrinsics/pack_generic.c:316: warning: passing argument 3 of 'pack_internal' from incompatible pointer type
../../../../libgfortran/intrinsics/pack_generic.c:331: warning: passing argument 3 of 'pack_internal' from incompatible pointer type
../../../../libgfortran/intrinsics/signal.c:201: warning: cast to pointer from integer of different size
../../../../libgfortran/intrinsics/signal.c:208: warning: cast to pointer from integer of different size
../../../../libgfortran/intrinsics/signal.c:229: warning: cast to pointer from integer of different size
../../../../libgfortran/intrinsics/signal.c:236: warning: cast to pointer from integer of different size
../../../../libgfortran/intrinsics/spread_generic.c:136: warning: format '%d' expects type 'int', but argument 2 has type 'index_type'
../../../../libgfortran/intrinsics/spread_generic.c:147: warning: format '%d' expects type 'int', but argument 2 has type 'index_type'
../../../../libgfortran/intrinsics/unpack_generic.c:201: warning: passing argument 3 of 'unpack_internal' from incompatible pointer type
../../../../libgfortran/intrinsics/unpack_generic.c:217: warning: passing argument 3 of 'unpack_internal' from incompatible pointer type
../../../../libgfortran/intrinsics/unpack_generic.c:233: warning: passing argument 3 of 'unpack_internal' from incompatible pointer type
../../../../libgfortran/intrinsics/unpack_generic.c:253: warning: passing argument 3 of 'unpack_internal' from incompatible pointer type
Comment 14 Francois-Xavier Coudert 2007-10-18 13:22:39 UTC
(In reply to comment #13)
> ../../../libgfortran/runtime/environ.c:312: warning: 'init_choice' defined but
> not used
> ../../../libgfortran/runtime/environ.c:339: warning: 'show_choice' defined but
> not used

These two have been removed by Ben Elliston.

> ../../../libgfortran/runtime/backtrace.c:66: warning: 'local_strcasestr'
> defined but not used

Fixed by the following:

Index: runtime/backtrace.c
===================================================================
--- runtime/backtrace.c (revision 129403)
+++ runtime/backtrace.c (working copy)
@@ -60,7 +60,18 @@ Boston, MA 02110-1301, USA.  */
 #include <ctype.h>


+/* Macros for common sets of capabilities: can we fork and exec, can
+   we use glibc-style backtrace functions, and can we use pipes.  */
+#define CAN_FORK (defined(HAVE_FORK) && defined(HAVE_EXECVP) \
+                 && defined(HAVE_WAIT))
+#define GLIBC_BACKTRACE (defined(HAVE_BACKTRACE) \
+                        && defined(HAVE_BACKTRACE_SYMBOLS))
+#define CAN_PIPE (CAN_FORK && defined(HAVE_PIPE) \
+                 && defined(HAVE_DUP2) && defined(HAVE_FDOPEN) \
+                 && defined(HAVE_CLOSE))

+
+#if GLIBC_BACKTRACE && CAN_PIPE
 static char *
 local_strcasestr (const char *s1, const char *s2)
 {
@@ -85,14 +96,7 @@ local_strcasestr (const char *s1, const
     }
 #endif
 }
-
-#define CAN_FORK (defined(HAVE_FORK) && defined(HAVE_EXECVP) \
-                 && defined(HAVE_WAIT))
-#define GLIBC_BACKTRACE (defined(HAVE_BACKTRACE) \
-                        && defined(HAVE_BACKTRACE_SYMBOLS))
-#define CAN_PIPE (CAN_FORK && defined(HAVE_PIPE) \
-                 && defined(HAVE_DUP2) && defined(HAVE_FDOPEN) \
-                 && defined(HAVE_CLOSE))
+#endif


 #if GLIBC_BACKTRACE


> ../../../libgfortran/runtime/main.c:179: warning: passing argument 1 of 'free'
> discards qualifiers from pointer target type

Fixed by:

Index: runtime/main.c
===================================================================
--- runtime/main.c      (revision 129403)
+++ runtime/main.c      (working copy)
@@ -176,5 +176,5 @@ cleanup (void)
   close_units ();

   if (please_free_exe_path_when_done)
-    free (exe_path);
+    free ((char *) exe_path);
 }


> ../../../../libgfortran/intrinsics/signal.c:201: warning: cast to pointer from
> integer of different size
> ../../../../libgfortran/intrinsics/signal.c:208: warning: cast to pointer from
> integer of different size
> ../../../../libgfortran/intrinsics/signal.c:229: warning: cast to pointer from
> integer of different size
> ../../../../libgfortran/intrinsics/signal.c:236: warning: cast to pointer from
> integer of different size

This should be silenced by:

Index: intrinsics/signal.c
===================================================================
--- intrinsics/signal.c (revision 129403)
+++ intrinsics/signal.c (working copy)
@@ -198,14 +198,14 @@ alarm_sub_int_i4 (int *seconds, int *han
 #if defined (SIGALRM) && defined (HAVE_ALARM) && defined (HAVE_SIGNAL)
   if (status != NULL)
     {
-      if (signal (SIGALRM, (void (*)(int)) *handler) == SIG_ERR)
+      if (signal (SIGALRM, (void (*)(int)) (INTPTR_T) *handler) == SIG_ERR)
        *status = -1;
       else
        *status = alarm (*seconds);
     }
   else
     {
-      signal (SIGALRM, (void (*)(int)) *handler);
+      signal (SIGALRM, (void (*)(int)) (INTPTR_T) *handler);
       alarm (*seconds);
     }
 #else
@@ -226,14 +226,14 @@ alarm_sub_int_i8 (int *seconds, int *han
 #if defined (SIGALRM) && defined (HAVE_ALARM) && defined (HAVE_SIGNAL)
   if (status != NULL)
     {
-      if (signal (SIGALRM, (void (*)(int)) *handler) == SIG_ERR)
+      if (signal (SIGALRM, (void (*)(int)) (INTPTR_T) *handler) == SIG_ERR)
        *status = -1;
       else
        *status = alarm (*seconds);
     }
   else
     {
-      signal (SIGALRM, (void (*)(int)) *handler);
+      signal (SIGALRM, (void (*)(int)) (INTPTR_T) *handler);
       alarm (*seconds);
     }
 #else


> ../../../libgfortran/intrinsics/spread_generic.c:136: warning: format '%d'
> expects type 'int', but argument 2 has type 'long int'
> ../../../libgfortran/intrinsics/spread_generic.c:147: warning: format '%d'
> expects type 'int', but argument 2 has type 'long int'

Fixed by:

Index: intrinsics/spread_generic.c
===================================================================
--- intrinsics/spread_generic.c (revision 129403)
+++ intrinsics/spread_generic.c (working copy)
@@ -131,9 +131,9 @@ spread_internal (gfc_array_char *ret, co

                  if (ret_extent != ncopies)
                    runtime_error("Incorrect extent in return value of SPREAD"
-                                 " intrinsic in dimension %d: is %ld,"
-                                 " should be %ld", n+1, (long int) ret_extent,
-                                 (long int) ncopies);
+                                 " intrinsic in dimension %ld: is %ld,"
+                                 " should be %ld", (long int) n+1,
+                                 (long int) ret_extent, (long int) ncopies);
                }
              else
                {
@@ -142,8 +142,9 @@ spread_internal (gfc_array_char *ret, co
                    - source->dim[dim].lbound;
                  if (ret_extent != extent[dim])
                    runtime_error("Incorrect extent in return value of SPREAD"
-                                 " intrinsic in dimension %d: is %ld,"
-                                 " should be %ld", n+1, (long int) ret_extent,
+                                 " intrinsic in dimension %ld: is %ld,"
+                                 " should be %ld", (long int) n+1,
+                                 (long int) ret_extent,
                                  (long int) extent[dim]);

                  if (extent[dim] <= 0)


> ../../../libgfortran/io/list_read.c:1518: warning: argument 'type' might be
> clobbered by 'longjmp' or 'vfork'

This one is longstanding. We need to audit and see if there is a potential problem in making type volatile.


> ../../../libgfortran/intrinsics/pack_generic.c:316: warning: passing argument 3
> of 'pack_internal' from incompatible pointer type
> ../../../libgfortran/intrinsics/pack_generic.c:331: warning: passing argument 3
> of 'pack_internal' from incompatible pointer type
> ../../../libgfortran/intrinsics/unpack_generic.c:201: warning: passing argument
> 3 of 'unpack_internal' from incompatible pointer type
> ../../../libgfortran/intrinsics/unpack_generic.c:217: warning: passing argument
> 3 of 'unpack_internal' from incompatible pointer type
> ../../../libgfortran/intrinsics/unpack_generic.c:233: warning: passing argument
> 3 of 'unpack_internal' from incompatible pointer type
> ../../../libgfortran/intrinsics/unpack_generic.c:253: warning: passing argument
> 3 of 'unpack_internal' from incompatible pointer type

These ones are worrying me. I think they were introduced by Thomas Koenig. Thomas, can you give it a look?
Comment 15 Thomas Koenig 2007-12-27 15:00:25 UTC
Subject: Bug 22423

Author: tkoenig
Date: Thu Dec 27 15:00:10 2007
New Revision: 131204

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=131204
Log:
2007-12-27  Thomas Koenig  <tkoenig@gcc.gnu.org>

	PR libfortran/22423
	* intrinsics/pack_generic.c (pack): Change type of mask argument
	to gfc_array_l1 * in prototype and function.
	(pack_char):  Likewise.
	* intrinsics/unpack_generic.c (unpack1):  Likewise.
	(unpack1_char):  Likewise.
	(unpack0):  Likewise.
	(unpack0_char):  Likewise.


Modified:
    trunk/libgfortran/ChangeLog
    trunk/libgfortran/intrinsics/pack_generic.c
    trunk/libgfortran/intrinsics/unpack_generic.c

Comment 16 Francois-Xavier Coudert 2009-05-03 16:28:49 UTC
Many new warnings:

../../../trunk/libgfortran/runtime/string.c: In function ‘compare0’:
../../../trunk/libgfortran/runtime/string.c:39: warning: comparison between signed and unsigned integer expressions

Fixed by:

Index: runtime/string.c
===================================================================
--- runtime/string.c	(revision 147057)
+++ runtime/string.c	(working copy)
@@ -36,7 +36,10 @@
 
   /* Strip trailing blanks from the Fortran string.  */
   len = fstrlen (s1, s1_len);
-  if (len != strlen(s2)) return 0; /* don't match */
+
+  if ((size_t) len != strlen(s2))
+    return 0; /* don't match */
+
   return strncasecmp (s1, s2, len) == 0;
 }


../../../trunk/libgfortran/io/transfer.c: In function ‘read_block_direct’:
../../../trunk/libgfortran/io/transfer.c:468: warning: comparison between signed and unsigned integer expressions

Fixed by:

Index: io/transfer.c
===================================================================
--- io/transfer.c	(revision 147057)
+++ io/transfer.c	(working copy)
@@ -465,7 +465,7 @@
   /* Check whether we exceed the total record length.  */
 
   if (dtp->u.p.current_unit->flags.has_recl
-      && (nbytes > dtp->u.p.current_unit->bytes_left))
+      && ((gfc_offset) nbytes > dtp->u.p.current_unit->bytes_left))
     {
       to_read_record = dtp->u.p.current_unit->bytes_left;
       short_record = 1;

 

../../../trunk/libgfortran/io/list_read.c: In function ‘nml_read_obj’:
../../../trunk/libgfortran/io/list_read.c:2464: warning: comparison between ‘bt’ and ‘enum <anonymous>’
../../../trunk/libgfortran/io/list_read.c: In function ‘nml_get_obj_data’:
../../../trunk/libgfortran/io/list_read.c:2712: warning: comparison between ‘bt’ and ‘enum <anonymous>’
../../../trunk/libgfortran/io/list_read.c:2734: warning: comparison between ‘bt’ and ‘enum <anonymous>’
../../../trunk/libgfortran/io/list_read.c:2768: warning: comparison between ‘bt’ and ‘enum <anonymous>’
../../../trunk/libgfortran/io/write.c: In function ‘nml_write_obj’:
../../../trunk/libgfortran/io/write.c:1261: warning: comparison between ‘bt’ and ‘enum <anonymous>’
../../../trunk/libgfortran/io/write.c:1339: warning: comparison between ‘bt’ and ‘enum <anonymous>’

All these come from the use of two different enums for one purpose: the bt enum in libgfortran/io/io.h and the anonymous enum containing GFC_DTYPE_UNKNOWN, GFC_DTYPE_INTEGER and friends in gcc/fortran/libgfortran.h. I'm not sure at all why there are two different enums, why their constants are sometimes used as if they were interchangeable (all the warnings above come from such uses), but what I know is that they shouldn't: the constants don't even come in the same order!

Compare:

  GFC_DTYPE_UNKNOWN = 0,        
  GFC_DTYPE_INTEGER,            
  GFC_DTYPE_LOGICAL,            
  GFC_DTYPE_REAL,
  GFC_DTYPE_COMPLEX,
  GFC_DTYPE_DERIVED,
  GFC_DTYPE_CHARACTER

with

  BT_NULL, /* ok, null and unknown are close enough */
  BT_INTEGER,
  BT_LOGICAL,
  BT_CHARACTER, /* oops */
  BT_REAL, /* re-oops */
  BT_COMPLEX /* final oops */
  /* and where is "derived"? */
Comment 17 Jerry DeLisle 2009-05-03 19:29:34 UTC
There is a warning in list_read.c left over from the big IO patch that was merged in.
Comment 18 Francois-Xavier Coudert 2009-05-07 21:42:34 UTC
Subject: Bug 22423

Author: fxcoudert
Date: Thu May  7 21:42:22 2009
New Revision: 147254

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=147254
Log:
	PR fortran/22423

	* io/transfer.c (read_block_direct): Avoid warning.
	* runtime/string.c (compare0): Avoid warning.

Modified:
    trunk/libgfortran/ChangeLog
    trunk/libgfortran/io/transfer.c
    trunk/libgfortran/runtime/string.c

Comment 19 Francois-Xavier Coudert 2009-05-07 22:03:06 UTC
We're left with the following:

../../../trunk/libgfortran/io/list_read.c: In function ‘nml_read_obj’:
../../../trunk/libgfortran/io/list_read.c:2464: warning: comparison between
‘bt’ and ‘enum <anonymous>’
../../../trunk/libgfortran/io/list_read.c: In function ‘nml_get_obj_data’:
../../../trunk/libgfortran/io/list_read.c:2712: warning: comparison between
‘bt’ and ‘enum <anonymous>’
../../../trunk/libgfortran/io/list_read.c:2734: warning: comparison between
‘bt’ and ‘enum <anonymous>’
../../../trunk/libgfortran/io/list_read.c:2768: warning: comparison between
‘bt’ and ‘enum <anonymous>’
../../../trunk/libgfortran/io/write.c: In function ‘nml_write_obj’:
../../../trunk/libgfortran/io/write.c:1261: warning: comparison between ‘bt’
and ‘enum <anonymous>’
../../../trunk/libgfortran/io/write.c:1339: warning: comparison between ‘bt’
and ‘enum <anonymous>’
Comment 20 Jerry DeLisle 2009-05-27 01:22:19 UTC
Subject: Bug 22423

Author: jvdelisle
Date: Wed May 27 01:21:22 2009
New Revision: 147887

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=147887
Log:
2009-05-23  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	Backport from mainline:
	PR libfortran/37754
	* io/write_float.def: Simplify format calculation.
	
2009-05-23  Francois-Xavier Coudert  <fxcoudert@gcc.gnu.org>

	Backport from mainline:
	PR fortran/22423
	* io/transfer.c (read_block_direct): Avoid warning.

2009-05-23  Janne Blomqvist  <jb@gcc.gnu.org>

	Backport from mainline:
	PR libfortran/39667
	* io/file_pos.c (st_rewind): Don't truncate or flush.
	* io/intrinsics.c (fgetc): Flush if switching mode.
	(fputc): Likewise.

2009-05-23  Janne Blomqvist  <jb@gcc.gnu.org>

	Backport from mainline:
	PR libfortran/39782
	* io/transfer.c (data_transfer_init): Don't flush before seek.

2009-05-23  Janne Blomqvist  <jb@gcc.gnu.org>

	Backport from mainline:
	* io/io.h (is_preconnected): Remove prototype.
	* io/unix.c (is_preconnected): Remove function.

2009-05-23  Janne Blomqvist  <jb@gcc.gnu.org>

	Backport from mainline:
	PR libfortran/38668
	* io/transfer.c (finalize_transfer): Don't flush for advance='no'.

2009-05-23 Danny Smith  <dannysmith@clear.net.nz>

	Backport from mainline:
	* io/write.c (itoa) : Rename back to gfc_itoa.
	(write_i): Adjust call to write_decimal.
	(write_integer):  Use gfc_itoa.

2009-05-23  Janne Blomqvist  <jb@gcc.gnu.org>

	Backport from mainline:
	* io/io.h (move_pos_offset): Remove prototype.
	* io/transfer.c (formatted_transfer_scalar_read): Use sseek
	instead of move_pos_offset.
	* io/unix.c (move_pos_offset): Remove.

2009-05-23  Janne Blomqvist  <jb@gcc.gnu.org>

	Backport from mainline:
	PR libfortran/39665 libfortran/39702 libfortran/39709
	* io/io.h (st_parameter_dt): Revert aligned attribute from u.p.value.
	* io/list_read.c (read_complex): Read directly into user pointer.
	(read_real): Likewise.
	(list_formatted_read_scalar): Update read_complex and read_real calls.
	(nml_read_obj): Read directly into user pointer.

2009-05-23  Janne Blomqvist  <jb@gcc.gnu.org>

	Backport from mainline:
	PR libfortran/39665
	* io/io.h (st_parameter_dt): Add aligned attribute to u.p.value.
	* io/read.c (convert_real): Add note about alignment requirements.

2009-05-23  Janne Blomqvist  <jb@gcc.gnu.org>

	Backport from mainline:
	* io/open.c (already_open): Test for POSIX close return value.
	* io/unit.c (close_unit_1): Likewise.
	* io/unix.c (raw_close): Return 0 for success for preconnected units.

2009-05-23  Janne Blomqvist  <jb@gcc.gnu.org>

	Backport from mainline:
	* runtime/error.c (gfc_itoa): Move to io/write.c
	(xtoa): Rename to gfc_xtoa.
	* runtime/backtrace.c (show_backtrace): Call gfc_xtoa.
	* libgfortran.h (gfc_itoa): Remove prototype.
	(xtoa): Rename prototype to gfc_xtoa.
	* io/list_read.c (nml_read_obj): Use size_t for string length.
	* io/transfer.c (read_block_direct): Change nbytes arg from
	pointer to value.
	(unformatted_read): Minor cleanup, call read_block_directly properly.
	(skip_record): Use ssize_t.
	(next_record_w_unf): Avoid stell() call by calling sseek with SEEK_CUR.
	(iolength_transfer): Make sure to multiply before cast.
	* io/intrinsics.c (fgetc): Remove unnecessary variable.
	* io/format.c (format_hash): Use gfc_charlen_type.
	* io/write.c (itoa): Move from runtime/error.c:gfc_itoa, rename,
	make static.
	(write_i): Call with pointer to itoa.
	(write_z): Call with pointer to gfc_xtoa.
	(write_integer): Pointer to itoa.
	(nml_write_obj): Type cleanup, don't call strlen in loop.
	
2009-05-23  H.J. Lu  <hongjiu.lu@intel.com>

	Backport from mainline:
	PR libgfortran/39664
	* io/unix.c (raw_close): Don't close STDOUT_FILENO,
	STDERR_FILENO nor STDIN_FILENO.

2009-05-23  David Edelsohn  <edelsohn@gnu.org>
	
	Backport from mainline:
	* io/io.h (struct stream): Rename truncate to trunc.
	(struncate): Same.
	* io/unix.c (raw_init): Rename truncate to trunc.
	(buf_init): Same.
	(open_internal): Same.
	
2009-05-23  Daniel Kraft  <d@domob.eu>

	Backport from mainline:
	PR fortran/38654
	* io/read.c (read_f): Reworked to speed up floating point parsing.
	(convert_real): Use pointer-casting instead of memcpy and temporaries.

2009-05-23  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	Backport from mainline:
	PR libfortran/37754
	* io/io.h (format_hash_entry): New structure for hash table.
	(format_hash_table): The hash table itself.
	(free_format_data): Revise function prototype.
	(free_format_hash_table, init_format_hash,
	free_format_hash): New function prototypes.
	* io/unit.c (close_unit_1): Use free_format_hash_table.
	* io/transfer.c (st_read_done, st_write_done): Free format data if
	internal unit.
	* io/format.c (free_format_hash_table): New function that frees any
	memory allocated previously for cached format data.
	(reset_node): New static helper function to reset the format counters
	for a format node.
	(reset_fnode_counters): New static function recursively calls reset_node
	to traverse the	fnode tree.
	(format_hash): New simple hash function based on XOR, probabalistic,
	tosses collisions.
	(save_parsed_format): New static function to save the parsed format
	data to use again.
	(find_parsed_format): New static function searches the hash table
	looking for a match.
	(free_format_data): Revised to accept pointer to format data rather than
	the dtp pointer so that the function can be used in more places.
	(format_lex): Editorial.
	(parse_format_list): Set flag used to determine of format data hashing
	is to be used.  Internal units are not persistent enough for this.
	(revert): Move to ne location in file.
	(parse_format): Use new functions to look for previously parsed
	format strings and use them rather than re-parse.  If not found, saves
	the parsed format data for later use.
	
2009-05-23  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	Backport from mainline:
	PR libfortran/37754
	* io/transfer.c (formatted_transfer_scalar): Remove this function by
	factoring it into two new functions, one for read and one for write,
	eliminating all the conditionals for read or write mode.
	(formatted transfer_scalar_read): New function.
	(formatted transfer_scalar_write): New function.
	(formatted_transfer): Use new functions.

2009-05-23  Janne Blomqvist  <jb@gcc.gnu.org>

	Backport from mainline:
	PR libfortran/25561 libfortran/37754
	* io/io.h (struct stream): Define new stream interface function
	pointers, and inline functions for accessing it.
	(struct fbuf): Use int instead of size_t, remove flushed element.
	(mem_alloc_w): New prototype.
	(mem_alloc_r): New prototype.
	(stream_at_bof): Remove prototype.
	(stream_at_eof): Remove prototype.
	(file_position): Remove prototype.
	(flush): Remove prototype.
	(stream_offset): Remove prototype.
	(unit_truncate): New prototype.
	(read_block_form): Change to return pointer, int* argument.
	(hit_eof): New prototype.
	(fbuf_init): Change prototype.
	(fbuf_reset): Change prototype.
	(fbuf_alloc): Change prototype.
	(fbuf_flush): Change prototype.
	(fbuf_seek): Change prototype.
	(fbuf_read): New prototype.
	(fbuf_getc_refill): New prototype.
	(fbuf_getc): New inline function.
	* io/fbuf.c (fbuf_init): Use int, get rid of flushed.
	(fbuf_debug): New function.
	(fbuf_reset): Flush, and return position offset.
	(fbuf_alloc): Simplify, don't flush, just realloc.
	(fbuf_flush): Make usable for read mode, salvage remaining bytes.
	(fbuf_seek): New whence argument.
	(fbuf_read): New function.
	(fbuf_getc_refill): New function.
	* io/file_pos.c (formatted_backspace): Use new stream interface.
	(unformatted_backspace): Likewise.
	(st_backspace): Make sure format buffer is reset, use new stream
	interface, use unit_truncate.
	(st_endfile): Likewise.
	(st_rewind): Likewise.
	* io/intrinsics.c: Use new stream interface.
	* io/list_read.c (push_char): Don't use u.p.scratch, use realloc
	to resize.
	(free_saved): Don't check u.p.scratch.
	(next_char): Use new stream interface, use fbuf_getc() for external files.
	(finish_list_read): flush format buffer.
	(nml_query): Update to use modified interface:s
	* io/open.c (test_endfile): Use new stream interface.
	(edit_modes): Likewise.
	(new_unit): Likewise, set bytes_left to 1 for stream files.
	* io/read.c (read_l): Use new read_block_form interface.
	(read_utf8): Likewise.
	(read_utf8_char1): Likewise.
	(read_default_char1): Likewise.
	(read_utf8_char4): Likewise.
	(read_default_char4): Likewise.
	(read_a): Likewise.
	(read_a_char4): Likewise.
	(read_decimal): Likewise.
	(read_radix): Likewise.
	(read_f): Likewise.
	* io/transfer.c (read_sf): Use fbuf_read and mem_alloc_r, remove
	usage of u.p.line_buffer.
	(read_block_form): Update interface to return pointer, use
	fbuf_read for direct access.
	(read_block_direct): Update to new stream interface.
	(write_block): Use mem_alloc_w for internal I/O.
	(write_buf): Update to new stream interface.
	(formatted_transfer_scalar): Don't use u.p.line_buffer, use
	fbuf_seek for external files.
	(us_read): Update to new stream interface.
	(us_write): Likewise.
	(data_transfer_init): Always check if we switch modes and flush.
	(skip_record): Use new stream interface, fix comparison.
	(next_record_r): Check for and reset u.p.at_eof, use new stream
	interface, use fbuf_getc for spacing.
	(write_us_marker): Update to new stream interface, don't inline.
	(next_record_w_unf): Likewise.
	(sset): New function.
	(next_record_w): Use new stream interface, use fbuf for printing
	newline.
	(next_record): Use new stream interface.
	(finalize_transfer): Remove sfree call, use new stream interface.
	(st_iolength_done): Don't use u.p.scratch.
	(st_read): Don't check for end of file.
	(st_read_done): Don't use u.p.scratch, use unit_truncate.
	(hit_eof): New function.
	* io/unit.c (init_units): Always init fbuf for formatted units.
	(update_position): Use new stream interface.
	(unit_truncate): New function.
	(finish_last_advance_record): Use fbuf to print newline.
	* io/unix.c: Remove unused SSIZE_MAX macro.
	(BUFFER_SIZE): Make static const variable rather than macro.
	(struct unix_stream): Remove dirty_offset, len, method,
	small_buffer. Order elements by decreasing size.
	(struct int_stream): Remove.
	(move_pos_offset): Remove usage of dirty_offset.
	(reset_stream): Remove.
	(do_read): Rename to raw_read, update to match new stream
	interface.
	(do_write): Rename to raw_write, update to new stream interface.
	(raw_seek): New function.
	(raw_tell): New function.
	(raw_truncate): New function.
	(raw_close): New function.
	(raw_flush): New function.
	(raw_init): New function.
	(fd_alloc): Remove.
	(fd_alloc_r_at): Remove.
	(fd_alloc_w_at): Remove.
	(fd_sfree): Remove.
	(fd_seek): Remove.
	(fd_truncate): Remove.
	(fd_sset): Remove.
	(fd_read): Remove.
	(fd_write): Remove.
	(fd_close): Remove.
	(fd_open): Remove.
	(fd_flush): Rename to buf_flush, update to new stream interface
	and unix_stream.
	(buf_read): New function.
	(buf_write): New function.
	(buf_seek): New function.
	(buf_tell): New function.
	(buf_truncate): New function.
	(buf_close): New function.
	(buf_init): New function.
	(mem_alloc_r_at): Rename to mem_alloc_r, change prototype.
	(mem_alloc_w_at): Rename to mem_alloc_w, change prototype.
	(mem_read): Change to match new stream interface.
	(mem_write): Likewise.
	(mem_seek): Likewise.
	(mem_tell): Likewise.
	(mem_truncate): Likewise.
	(mem_close): Likewise.
	(mem_flush): New function.
	(mem_sfree): Remove.
	(empty_internal_buffer): Cast to correct type.
	(open_internal): Use correct type, init function pointers.
	(fd_to_stream): Test whether to open file as buffered or raw.
	(output_stream): Remove mode set.
	(error_stream): Likewise.
	(flush_all_units_1): Use new stream interface.
	(flush_all_units): Likewise.
	(stream_at_bof): Remove.
	(stream_at_eof): Remove.
	(file_position): Remove.
	(file_length): Update logic to use stream interface.
	(flush): Remove.
	(stream_offset): Remove.
	* io/write.c (write_utf8_char4): Use int instead of size_t.
	(write_x): Extra safety check.
	(namelist_write_newline): Use new stream interface.


Modified:
    branches/gcc-4_4-branch/libgfortran/ChangeLog
    branches/gcc-4_4-branch/libgfortran/io/fbuf.c
    branches/gcc-4_4-branch/libgfortran/io/file_pos.c
    branches/gcc-4_4-branch/libgfortran/io/format.c
    branches/gcc-4_4-branch/libgfortran/io/intrinsics.c
    branches/gcc-4_4-branch/libgfortran/io/io.h
    branches/gcc-4_4-branch/libgfortran/io/list_read.c
    branches/gcc-4_4-branch/libgfortran/io/open.c
    branches/gcc-4_4-branch/libgfortran/io/read.c
    branches/gcc-4_4-branch/libgfortran/io/transfer.c
    branches/gcc-4_4-branch/libgfortran/io/unit.c
    branches/gcc-4_4-branch/libgfortran/io/unix.c
    branches/gcc-4_4-branch/libgfortran/io/write.c
    branches/gcc-4_4-branch/libgfortran/io/write_float.def
    branches/gcc-4_4-branch/libgfortran/libgfortran.h
    branches/gcc-4_4-branch/libgfortran/runtime/backtrace.c
    branches/gcc-4_4-branch/libgfortran/runtime/error.c

Comment 21 Francois-Xavier Coudert 2009-06-14 09:06:19 UTC
There's still a bunch of warnings:

../../../trunk/libgfortran/io/list_read.c: In function ‘nml_read_obj’:
../../../trunk/libgfortran/io/list_read.c:2345:5: warning: case value ‘6’ not in enumerated type ‘bt’
../../../trunk/libgfortran/io/list_read.c:2392:4: warning: case value ‘6’ not in enumerated type ‘bt’
../../../trunk/libgfortran/io/list_read.c:2469:31: warning: comparison between ‘bt’ and ‘enum <anonymous>’
../../../trunk/libgfortran/io/list_read.c: In function ‘nml_get_obj_data’:
../../../trunk/libgfortran/io/list_read.c:2717:20: warning: comparison between ‘bt’ and ‘enum <anonymous>’
../../../trunk/libgfortran/io/list_read.c:2739:28: warning: comparison between ‘bt’ and ‘enum <anonymous>’
../../../trunk/libgfortran/io/list_read.c:2773:16: warning: comparison between ‘bt’ and ‘enum <anonymous>’
../../../trunk/libgfortran/io/write.c: In function ‘nml_write_obj’:
../../../trunk/libgfortran/io/write.c:1261:17: warning: comparison between ‘bt’ and ‘enum <anonymous>’
../../../trunk/libgfortran/io/write.c:1303:5: warning: case value ‘6’ not in enumerated type ‘bt’
../../../trunk/libgfortran/io/write.c:1339:15: warning: comparison between ‘bt’ and ‘enum <anonymous>’
../../../trunk/libgfortran/io/write.c:1372:6: warning: case value ‘6’ not in enumerated type ‘bt’


There is something quite wrong done here with type "bt" and putting values from a different enum into it.
Comment 22 Francois-Xavier Coudert 2009-07-05 09:23:59 UTC
*** Bug 40545 has been marked as a duplicate of this bug. ***
Comment 23 Francois-Xavier Coudert 2009-07-05 09:24:40 UTC
Additional new warning:

intrinsics/iso_c_binding.c: In Function "__iso_c_binding_c_f_pointer_u0":
libgfortran/intrinsics/iso_c_binding.c:112:20: Warning: "ub" may be used uninitialized in this function
Comment 24 Tobias Burnus 2009-07-13 06:26:53 UTC
Subject: Bug 22423

Author: burnus
Date: Mon Jul 13 06:26:38 2009
New Revision: 149545

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=149545
Log:
2009-07-12  Tobias Burnus  <burnus@net-b.de>
            Philippe Marguinaud <philippe.marguinaud@meteo.fr>

        PR fortran/40588
        * primary.c (match_charkind_name): Fix condition for $ matching.

        PR libfortran/22423
        * libgfortran.h: Typedef the GFC_DTYPE_* enum.

2009-07-12  Tobias Burnus  <burnus@net-b.de>

        PR libfortran/22423
        * io/io.h (namelist_type): Use the proper enum for GFC_DTYPE_*.
        * intrinsics/iso_c_binding.c (c_f_pointer_u0): Make sure
        variable is initialized to silence warning.


Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/libgfortran.h
    trunk/gcc/fortran/primary.c
    trunk/libgfortran/ChangeLog
    trunk/libgfortran/intrinsics/iso_c_binding.c
    trunk/libgfortran/io/io.h

Comment 25 Tobias Burnus 2009-07-13 06:31:59 UTC
Fixed (cf. comment 24) the warning of comment 21 and comment 23. If a new warning is spotted, feel free to open a new PR or reopen this PR.