public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "burnus at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/53667] New: Cray pointer: Wrong result with optimizations Date: Thu, 14 Jun 2012 07:05:00 -0000 [thread overview] Message-ID: <bug-53667-4@http.gcc.gnu.org/bugzilla/> (raw) http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53667 Bug #: 53667 Summary: Cray pointer: Wrong result with optimizations Classification: Unclassified Product: gcc Version: 4.8.0 Status: UNCONFIRMED Keywords: wrong-code Severity: normal Priority: P3 Component: fortran AssignedTo: unassigned@gcc.gnu.org ReportedBy: burnus@gcc.gnu.org Cf. thread at http://gcc.gnu.org/ml/fortran/2012-06/msg00077.html For the program at http://gcc.gnu.org/ml/fortran/2012-06/txt00004.txt, GCC generates (original dump) the code: object_holder_init (&object_holder); set_vals (&object_holder); print_vals (&object_holder); When using -O2, the latter becomes (optimized dump): object_holder_init (&object_holder); print_vals (&object_holder); object_holder ={v} {CLOBBER}; Both set_vals and print_vals contains code of the form: subroutine set_vals(oh) implicit none integer*8, intent(inout):: oh integer*8 :: obj(3) pointer(pobj, obj) pobj = oh which translates into: set_vals (integer(kind=8) & restrict oh) { integer(kind=8) pobj; integer(kind=8) obj[3] [value-expr: *(integer(kind=8)[3] *) pobj]; pobj = *oh; If one marks "print_val"'s dummy argument "oh" as "target" (and, hence, removes the "restrict"), GCC inlines "set_val" and the result is correct. The program also works (at any optimization level) with -fno-inline-small-functions. Or if all functions are inlined via -fwhole-program. It also works if one has a Cray-pointer dummy argument at: subroutine print_vals(pobj) integer*8 :: obj(3) pointer(pobj, obj) ... call free(pobj) * * * Related issue: Currently, gfortran calls *oh = _gfortran_malloc (&C.1885); ... _gfortran_free ((integer(kind=8) *) oh); (Cf. iresolve.c.) If one looks into libgfortran/intrinsics/malloc.c, it uses the trivial implementation. But then a simple BUILT_IN_MALLOC / BUILT_IN_FREE would do!
next reply other threads:[~2012-06-14 7:05 UTC|newest] Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top 2012-06-14 7:05 burnus at gcc dot gnu.org [this message] 2012-06-14 8:36 ` [Bug fortran/53667] " rguenth at gcc dot gnu.org 2012-06-14 9:07 ` [Bug middle-end/53667] " burnus at gcc dot gnu.org 2012-06-21 6:32 ` [Bug middle-end/53667] [4.6/4.7/4.8 Regression] " burnus at gcc dot gnu.org 2012-09-06 15:11 ` rguenth at gcc dot gnu.org 2012-09-07 9:01 ` rguenth at gcc dot gnu.org 2012-09-07 9:39 ` burnus at gcc dot gnu.org 2012-09-07 10:27 ` rguenth at gcc dot gnu.org 2012-09-07 10:30 ` rguenth at gcc dot gnu.org 2012-09-07 10:32 ` [Bug middle-end/53667] [4.6 " rguenth at gcc dot gnu.org 2013-04-12 16:27 ` jakub 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-53667-4@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: linkBe 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).