public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "kargl at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug fortran/47633] Result of COMPILER_VERSION() has NULL byte appended
Date: Mon, 07 Feb 2011 16:12:00 -0000	[thread overview]
Message-ID: <bug-47633-4-zJB5hLjrc9@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-47633-4@http.gcc.gnu.org/bugzilla/>

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

kargl at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |ASSIGNED
   Last reconfirmed|                            |2011.02.07 16:02:20
                 CC|                            |kargl at gcc dot gnu.org
     Ever Confirmed|0                           |1

--- Comment #1 from kargl at gcc dot gnu.org 2011-02-07 16:02:20 UTC ---
Confirmed.  Here's a tentative patch and testcase.

! { dg-do run }
! PR fortran/47633
program testenv
    use iso_fortran_env
    character(len=60) v
    integer n
    v = compiler_version()
    n = len(compiler_version())
    if (ichar(v(n:n)) /= 32) call abort()
end program testenv


troutmask:sgk[291] svn diff simplify.c
Index: simplify.c
===================================================================
--- simplify.c  (revision 169830)
+++ simplify.c  (working copy)
@@ -6837,7 +6837,6 @@ gfc_simplify_compiler_options (void)
   return result;
 }

-
 gfc_expr *
 gfc_simplify_compiler_version (void)
 {
@@ -6845,8 +6844,10 @@ gfc_simplify_compiler_version (void)
   size_t len;

   len = strlen ("GCC version ") + strlen (version_string) + 1;
-  buffer = (char*) alloca (len);
+  buffer = (char *) alloca (len);
   snprintf (buffer, len, "GCC version %s", version_string);
+  /* Remove the terminating NULL character. */
+  buffer[strlen(buffer)] = ' ';
   return gfc_get_character_expr (gfc_default_character_kind,
                                 &gfc_current_locus, buffer, len);
 }


  reply	other threads:[~2011-02-07 16:02 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-02-07 13:42 [Bug fortran/47633] New: " thenlich at users dot sourceforge.net
2011-02-07 16:12 ` kargl at gcc dot gnu.org [this message]
2011-02-07 16:20 ` [Bug fortran/47633] " jakub at gcc dot gnu.org
2011-02-07 17:49 ` sgk at troutmask dot apl.washington.edu
2011-02-07 18:10 ` jakub at gcc dot gnu.org
2011-02-07 19:13 ` burnus at gcc dot gnu.org
2011-02-07 19:37 ` sgk at troutmask dot apl.washington.edu
2011-02-13  0:05 ` tkoenig at gcc dot gnu.org
2011-02-13  0:51 ` sgk at troutmask dot apl.washington.edu
2011-02-14 17:25 ` burnus at gcc dot gnu.org
2011-02-15 19:39 ` kargl at gcc dot gnu.org
2011-02-15 19:46 ` kargl at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-47633-4-zJB5hLjrc9@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).