public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libfortran/32858]  New: printf-capabilities for runtime_error()
@ 2007-07-22 21:04 tkoenig at gcc dot gnu dot org
  2007-07-24 19:06 ` [Bug libfortran/32858] " jb at gcc dot gnu dot org
                   ` (12 more replies)
  0 siblings, 13 replies; 14+ messages in thread
From: tkoenig at gcc dot gnu dot org @ 2007-07-22 21:04 UTC (permalink / raw)
  To: gcc-bugs

It would be better if runtime_error() included printf-like capabilites,
for better error reporting.

The way forward is to make it a variadic function, which passes its
arguments to st_printf().  This, in turn, should be based on the
library printf() - family of functions because it offers more
capabilities (such as %ld).


-- 
           Summary: printf-capabilities for runtime_error()
           Product: gcc
           Version: 4.3.0
            Status: UNCONFIRMED
          Severity: enhancement
          Priority: P3
         Component: libfortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: tkoenig at gcc dot gnu dot org


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


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

* [Bug libfortran/32858] printf-capabilities for runtime_error()
  2007-07-22 21:04 [Bug libfortran/32858] New: printf-capabilities for runtime_error() tkoenig at gcc dot gnu dot org
@ 2007-07-24 19:06 ` jb at gcc dot gnu dot org
  2007-07-25  5:47 ` tkoenig at gcc dot gnu dot org
                   ` (11 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: jb at gcc dot gnu dot org @ 2007-07-24 19:06 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from jb at gcc dot gnu dot org  2007-07-24 19:06 -------
Confirmed. Also, st_sprintf could be directly replaced by s(n)printf.


-- 

jb at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|0                           |1
   Last reconfirmed|0000-00-00 00:00:00         |2007-07-24 19:06:23
               date|                            |


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


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

* [Bug libfortran/32858] printf-capabilities for runtime_error()
  2007-07-22 21:04 [Bug libfortran/32858] New: printf-capabilities for runtime_error() tkoenig at gcc dot gnu dot org
  2007-07-24 19:06 ` [Bug libfortran/32858] " jb at gcc dot gnu dot org
@ 2007-07-25  5:47 ` tkoenig at gcc dot gnu dot org
  2007-07-25  8:46 ` jb at gcc dot gnu dot org
                   ` (10 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: tkoenig at gcc dot gnu dot org @ 2007-07-25  5:47 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from tkoenig at gcc dot gnu dot org  2007-07-25 05:47 -------
Working on a patch.

I have already gotten rid of st_sprintf.

The nice thing about vsprintf is that it has a gcc builtin, so
we should be able to use it even if the system doesn't have it.


-- 

tkoenig at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|unassigned at gcc dot gnu   |tkoenig at gcc dot gnu dot
                   |dot org                     |org
             Status|NEW                         |ASSIGNED
   Last reconfirmed|2007-07-24 19:06:23         |2007-07-25 05:47:33
               date|                            |


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


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

* [Bug libfortran/32858] printf-capabilities for runtime_error()
  2007-07-22 21:04 [Bug libfortran/32858] New: printf-capabilities for runtime_error() tkoenig at gcc dot gnu dot org
  2007-07-24 19:06 ` [Bug libfortran/32858] " jb at gcc dot gnu dot org
  2007-07-25  5:47 ` tkoenig at gcc dot gnu dot org
@ 2007-07-25  8:46 ` jb at gcc dot gnu dot org
  2007-07-25 11:39 ` burnus at gcc dot gnu dot org
                   ` (9 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: jb at gcc dot gnu dot org @ 2007-07-25  8:46 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from jb at gcc dot gnu dot org  2007-07-25 08:46 -------
Related to this, a string library for libgfortran:
http://gcc.gnu.org/ml/fortran/2007-07/msg00463.html


-- 


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


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

* [Bug libfortran/32858] printf-capabilities for runtime_error()
  2007-07-22 21:04 [Bug libfortran/32858] New: printf-capabilities for runtime_error() tkoenig at gcc dot gnu dot org
                   ` (2 preceding siblings ...)
  2007-07-25  8:46 ` jb at gcc dot gnu dot org
@ 2007-07-25 11:39 ` burnus at gcc dot gnu dot org
  2007-07-28 22:00 ` tkoenig at gcc dot gnu dot org
                   ` (8 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: burnus at gcc dot gnu dot org @ 2007-07-25 11:39 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from burnus at gcc dot gnu dot org  2007-07-25 11:39 -------
Reminder: If implemented, change the PACK library function to print out the
size of LHS/RHS array (cf. PR 30814 & PR 32890).


-- 


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


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

* [Bug libfortran/32858] printf-capabilities for runtime_error()
  2007-07-22 21:04 [Bug libfortran/32858] New: printf-capabilities for runtime_error() tkoenig at gcc dot gnu dot org
                   ` (3 preceding siblings ...)
  2007-07-25 11:39 ` burnus at gcc dot gnu dot org
@ 2007-07-28 22:00 ` tkoenig at gcc dot gnu dot org
  2007-07-28 22:04 ` tkoenig at gcc dot gnu dot org
                   ` (7 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: tkoenig at gcc dot gnu dot org @ 2007-07-28 22:00 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from tkoenig at gcc dot gnu dot org  2007-07-28 21:59 -------
Created an attachment (id=13995)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=13995&action=view)
a patch.  Unfortunately, it doesn't print out any error messages right now.


-- 


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


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

* [Bug libfortran/32858] printf-capabilities for runtime_error()
  2007-07-22 21:04 [Bug libfortran/32858] New: printf-capabilities for runtime_error() tkoenig at gcc dot gnu dot org
                   ` (4 preceding siblings ...)
  2007-07-28 22:00 ` tkoenig at gcc dot gnu dot org
@ 2007-07-28 22:04 ` tkoenig at gcc dot gnu dot org
  2007-07-29  8:39 ` tkoenig at gcc dot gnu dot org
                   ` (6 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: tkoenig at gcc dot gnu dot org @ 2007-07-28 22:04 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #6 from tkoenig at gcc dot gnu dot org  2007-07-28 22:04 -------
There are also a few other issues with the incomplete patch.
vsnprintf can be replaced by __builtin_vsnprintf
on systems where it isn't available.  I'll iron that out
when I have the main functionality working.


-- 


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


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

* [Bug libfortran/32858] printf-capabilities for runtime_error()
  2007-07-22 21:04 [Bug libfortran/32858] New: printf-capabilities for runtime_error() tkoenig at gcc dot gnu dot org
                   ` (5 preceding siblings ...)
  2007-07-28 22:04 ` tkoenig at gcc dot gnu dot org
@ 2007-07-29  8:39 ` tkoenig at gcc dot gnu dot org
  2007-07-29 15:58 ` jb at gcc dot gnu dot org
                   ` (5 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: tkoenig at gcc dot gnu dot org @ 2007-07-29  8:39 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #7 from tkoenig at gcc dot gnu dot org  2007-07-29 08:39 -------
I think I understand what's wrong with my patch now: The
stream initialized with init_error_stream was never flushed.

I think I'll go with a naked write() call, which is

a) simpler

b) more robust.


-- 


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


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

* [Bug libfortran/32858] printf-capabilities for runtime_error()
  2007-07-22 21:04 [Bug libfortran/32858] New: printf-capabilities for runtime_error() tkoenig at gcc dot gnu dot org
                   ` (6 preceding siblings ...)
  2007-07-29  8:39 ` tkoenig at gcc dot gnu dot org
@ 2007-07-29 15:58 ` jb at gcc dot gnu dot org
  2007-07-29 16:33 ` tkoenig at gcc dot gnu dot org
                   ` (4 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: jb at gcc dot gnu dot org @ 2007-07-29 15:58 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #8 from jb at gcc dot gnu dot org  2007-07-29 15:58 -------
I had a look at your patch, and one thing which looks worrying is the use of
sprintf all over the place. That's just a recipe for buffer overflows,
especially when combined with %s formatting.

I think Tobi's suggestion to use libiberty dyn-string is good.

(In reply to comment #6)
> There are also a few other issues with the incomplete patch.
> vsnprintf can be replaced by __builtin_vsnprintf
> on systems where it isn't available.

Doesn't the compiler automatically take care of using builtin_vsnprintf?

(In reply to comment #7)
> I think I understand what's wrong with my patch now: The
> stream initialized with init_error_stream was never flushed.
> 
> I think I'll go with a naked write() call, which is
> 
> a) simpler
> 
> b) more robust.

This will mess up the indices in unix_stream, no? I suppose you could get
around that by flushing before writing, but that's the cardinal sin writing an
I/O library: Never, ever, ever flush to fix a bug. And yes, we have committed
this sin in multiple places in libgfortran. :(

More generally, see PR25561


-- 


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


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

* [Bug libfortran/32858] printf-capabilities for runtime_error()
  2007-07-22 21:04 [Bug libfortran/32858] New: printf-capabilities for runtime_error() tkoenig at gcc dot gnu dot org
                   ` (7 preceding siblings ...)
  2007-07-29 15:58 ` jb at gcc dot gnu dot org
@ 2007-07-29 16:33 ` tkoenig at gcc dot gnu dot org
  2007-07-29 18:55 ` patchapp at dberlin dot org
                   ` (3 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: tkoenig at gcc dot gnu dot org @ 2007-07-29 16:33 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #9 from tkoenig at gcc dot gnu dot org  2007-07-29 16:33 -------
Created an attachment (id=13999)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=13999&action=view)
Patch (current status)

This patch is currently bootstrapping on my machine.
Let's see how it works.


-- 

tkoenig at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
  Attachment #13995|0                           |1
        is obsolete|                            |


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


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

* [Bug libfortran/32858] printf-capabilities for runtime_error()
  2007-07-22 21:04 [Bug libfortran/32858] New: printf-capabilities for runtime_error() tkoenig at gcc dot gnu dot org
                   ` (8 preceding siblings ...)
  2007-07-29 16:33 ` tkoenig at gcc dot gnu dot org
@ 2007-07-29 18:55 ` patchapp at dberlin dot org
  2007-07-29 20:02 ` tkoenig at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: patchapp at dberlin dot org @ 2007-07-29 18:55 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #10 from patchapp at dberlin dot org  2007-07-29 18:55 -------
Subject: Bug number PR 32858

A patch for this bug has been added to the patch tracker.
The mailing list url for the patch is
http://gcc.gnu.org/ml/gcc-patches/2007-07/msg02070.html


-- 


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


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

* [Bug libfortran/32858] printf-capabilities for runtime_error()
  2007-07-22 21:04 [Bug libfortran/32858] New: printf-capabilities for runtime_error() tkoenig at gcc dot gnu dot org
                   ` (9 preceding siblings ...)
  2007-07-29 18:55 ` patchapp at dberlin dot org
@ 2007-07-29 20:02 ` tkoenig at gcc dot gnu dot org
  2007-07-30  6:12 ` tkoenig at gcc dot gnu dot org
  2007-07-30  9:30 ` pinskia at gcc dot gnu dot org
  12 siblings, 0 replies; 14+ messages in thread
From: tkoenig at gcc dot gnu dot org @ 2007-07-29 20:02 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #11 from tkoenig at gcc dot gnu dot org  2007-07-29 20:01 -------
Subject: Bug 32858

Author: tkoenig
Date: Sun Jul 29 20:01:45 2007
New Revision: 127049

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

        PR libfortran/32858
        PR libfortran/30814
        * configure.ac:  Added checks for presence of stdio.h and
        stdarg.h.  Test presence of vsnprintf().
        * configure: Regenerated.
        * config.h.in:  Regenerated.
        * libgfortran.h:  Include <stdio.h>.  Add printf attribute to
        prototype of runtime_error.  Remove prototype for st_sprintf.
        Add prototype for st_vprintf.
        * runtime/main.c (store_exec_path):  Replace st_sprintf by sprintf.
        * runtime/error.c (st_sprintf):  Remove.
        (runtime_error):  Rewrite as a variadic function.  Call
        st_vprintf().
        * intrinsics/pack_generic.c:  Output extents of LHS and RHS for
        bounds error.
        * io/open.c (new_unit):  Replace st_sprintf by sprintf.
        * io/list_read.c (convert_integer):  Likewise.
        (parse_repeat):  Likewise.
        (read_logical):  Likewise.
        (read_character):  Likewise.
        (parse_real):  Likewise.
        (read_real):  Likewise.
        (check_type):  Likewise.
        (nml_parse_qualifyer):  Likewise.
        (nml_read_obj):  Likewise.
        (nml_get_ojb_data):  Likewise.
        * io/unix.c (init_error_stream):  Remove.
        (tempfile):  Replace st_sprintf by sprintf.
        (st_vprintf):  New function.
        (st_printf):  Rewrite to call st_vprintf.
        * io/transfer.c (require_type):  Replace st_sprintf by sprintf.
        * io/format.c (format_error):  Likewise.
        * io/write.c (nml_write_obj):  Likewise.

2007-07-29  Thomas Koenig  <tkoenig@gcc.gnu.org>

        PR libfortran/32858
        PR libfortran/30814
        * gfortran.dg/pack_bounds_1.f90:  Adjust to new error message.


Modified:
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/testsuite/gfortran.dg/pack_bounds_1.f90
    trunk/libgfortran/ChangeLog
    trunk/libgfortran/config.h.in
    trunk/libgfortran/configure
    trunk/libgfortran/configure.ac
    trunk/libgfortran/intrinsics/pack_generic.c
    trunk/libgfortran/io/format.c
    trunk/libgfortran/io/list_read.c
    trunk/libgfortran/io/open.c
    trunk/libgfortran/io/transfer.c
    trunk/libgfortran/io/unix.c
    trunk/libgfortran/io/write.c
    trunk/libgfortran/libgfortran.h
    trunk/libgfortran/runtime/error.c
    trunk/libgfortran/runtime/main.c


-- 


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


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

* [Bug libfortran/32858] printf-capabilities for runtime_error()
  2007-07-22 21:04 [Bug libfortran/32858] New: printf-capabilities for runtime_error() tkoenig at gcc dot gnu dot org
                   ` (10 preceding siblings ...)
  2007-07-29 20:02 ` tkoenig at gcc dot gnu dot org
@ 2007-07-30  6:12 ` tkoenig at gcc dot gnu dot org
  2007-07-30  9:30 ` pinskia at gcc dot gnu dot org
  12 siblings, 0 replies; 14+ messages in thread
From: tkoenig at gcc dot gnu dot org @ 2007-07-30  6:12 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #12 from tkoenig at gcc dot gnu dot org  2007-07-30 06:11 -------
Fixed on trunk.  Closing.


-- 


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


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

* [Bug libfortran/32858] printf-capabilities for runtime_error()
  2007-07-22 21:04 [Bug libfortran/32858] New: printf-capabilities for runtime_error() tkoenig at gcc dot gnu dot org
                   ` (11 preceding siblings ...)
  2007-07-30  6:12 ` tkoenig at gcc dot gnu dot org
@ 2007-07-30  9:30 ` pinskia at gcc dot gnu dot org
  12 siblings, 0 replies; 14+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2007-07-30  9:30 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #13 from pinskia at gcc dot gnu dot org  2007-07-30 09:30 -------
Fixed as mentioned so closing.


-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED
   Target Milestone|---                         |4.3.0


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


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

end of thread, other threads:[~2007-07-30  9:30 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-07-22 21:04 [Bug libfortran/32858] New: printf-capabilities for runtime_error() tkoenig at gcc dot gnu dot org
2007-07-24 19:06 ` [Bug libfortran/32858] " jb at gcc dot gnu dot org
2007-07-25  5:47 ` tkoenig at gcc dot gnu dot org
2007-07-25  8:46 ` jb at gcc dot gnu dot org
2007-07-25 11:39 ` burnus at gcc dot gnu dot org
2007-07-28 22:00 ` tkoenig at gcc dot gnu dot org
2007-07-28 22:04 ` tkoenig at gcc dot gnu dot org
2007-07-29  8:39 ` tkoenig at gcc dot gnu dot org
2007-07-29 15:58 ` jb at gcc dot gnu dot org
2007-07-29 16:33 ` tkoenig at gcc dot gnu dot org
2007-07-29 18:55 ` patchapp at dberlin dot org
2007-07-29 20:02 ` tkoenig at gcc dot gnu dot org
2007-07-30  6:12 ` tkoenig at gcc dot gnu dot org
2007-07-30  9:30 ` pinskia 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).