public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "manu at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/57693] The program logically failed in case of used "int b += b++"
Date: Mon, 24 Jun 2013 10:05:00 -0000	[thread overview]
Message-ID: <bug-57693-4-clp4uyQnuU@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-57693-4@http.gcc.gnu.org/bugzilla/>

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

Manuel López-Ibáñez <manu at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |manu at gcc dot gnu.org

--- Comment #4 from Manuel López-Ibáñez <manu at gcc dot gnu.org> ---
> Both:
>  b += b++;
> And
>         d += d++;
> 
> are undefined what value b and d is going to be as there are no sequence
> point intbetween the two assignments.
> 
> They could be:
> temp = b;
> b++;
> b += temp;
> 
> or b++;
> b+=b;

Please, could we make more use of the FAQ? 

http://gcc.gnu.org/wiki/FAQ#undefinedbut

If you think the answer does not provide enough information, just extend the
answer there. (it could mention some example, and -Wsequence-points).

Otherwise, we have the same back and forth over and over again to the
frustration of users and the time waste of developers: what is UB? but my
program worked before! but my program works without optimizations! but I know
how it should work! can't gcc be consistent? but UB should not affect my
problem! I think this should not be UB!
>From gcc-bugs-return-424969-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Mon Jun 24 10:15:22 2013
Return-Path: <gcc-bugs-return-424969-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 5950 invoked by alias); 24 Jun 2013 10:15:22 -0000
Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm
Precedence: bulk
List-Id: <gcc-bugs.gcc.gnu.org>
List-Archive: <http://gcc.gnu.org/ml/gcc-bugs/>
List-Post: <mailto:gcc-bugs@gcc.gnu.org>
List-Help: <mailto:gcc-bugs-help@gcc.gnu.org>
Sender: gcc-bugs-owner@gcc.gnu.org
Delivered-To: mailing list gcc-bugs@gcc.gnu.org
Received: (qmail 5896 invoked by uid 48); 24 Jun 2013 10:15:18 -0000
From: "burnus at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug fortran/57696] New: Defined assignment for components not used when those are ALLOCATABLE
Date: Mon, 24 Jun 2013 10:15:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: new
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: fortran
X-Bugzilla-Version: 4.9.0
X-Bugzilla-Keywords: wrong-code
X-Bugzilla-Severity: normal
X-Bugzilla-Who: burnus at gcc dot gnu.org
X-Bugzilla-Status: UNCONFIRMED
X-Bugzilla-Priority: P3
X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org
X-Bugzilla-Target-Milestone: ---
X-Bugzilla-Flags:
X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status keywords bug_severity priority component assigned_to reporter cc
Message-ID: <bug-57696-4@http.gcc.gnu.org/bugzilla/>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: 7bit
X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/
Auto-Submitted: auto-generated
MIME-Version: 1.0
X-SW-Source: 2013-06/txt/msg01348.txt.bz2
Content-length: 1290

http://gcc.gnu.org/bugzilla/show_bug.cgi?idW696

            Bug ID: 57696
           Summary: Defined assignment for components not used when those
                    are ALLOCATABLE
           Product: gcc
           Version: 4.9.0
            Status: UNCONFIRMED
          Keywords: wrong-code
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: burnus at gcc dot gnu.org
                CC: pault at gcc dot gnu.org

The following prints
          42
          42
with gfortran and
 42
 20
with crayftn. Thus, gfortran does not use defined assignment - but it should.

Note: If "right%foo" is not allocated, the code segfaults with crayftn.


module m0
  implicit none
  type component
    integer :: i = 42
  contains
    procedure :: assign0
    generic :: assignment(=) => assign0
  end type
  type parent
    type(component), allocatable :: foo
  end type
contains
  elemental subroutine assign0(lhs,rhs)
    class(component), intent(INout) :: lhs
    class(component), intent(in) :: rhs
    lhs%i = 20
  end subroutine
end module

program main
  use m0
  implicit none
  type(parent) :: left, right
  allocate(right%foo)
  print *, right%foo
  left = right
  print *, left%foo
end


      parent reply	other threads:[~2013-06-24 10:05 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-06-24  7:46 [Bug c++/57693] New: " vlad94009277 at gmail dot com
2013-06-24  7:49 ` [Bug c++/57693] " pinskia at gcc dot gnu.org
2013-06-24  8:15 ` vlad94009277 at gmail dot com
2013-06-24  8:18 ` jakub at gcc dot gnu.org
2013-06-24 10:05 ` manu at gcc dot gnu.org [this message]

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-57693-4-clp4uyQnuU@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).