From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 12322 invoked by alias); 29 Jan 2015 18:31:46 -0000 Mailing-List: contact gdb-prs-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-prs-owner@sourceware.org Received: (qmail 12268 invoked by uid 48); 29 Jan 2015 18:31:44 -0000 From: "ed at catmur dot co.uk" To: gdb-prs@sourceware.org Subject: [Bug exp/17904] New: "Cannot access memory at address 0x0" for function returning reference evaluated within EVAL_AVOID_SIDE_EFFECTS Date: Thu, 29 Jan 2015 18:33:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gdb X-Bugzilla-Component: exp X-Bugzilla-Version: HEAD X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: ed at catmur dot co.uk X-Bugzilla-Status: NEW X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: unassigned at sourceware dot org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: http://sourceware.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2015-q1/txt/msg00137.txt.bz2 https://sourceware.org/bugzilla/show_bug.cgi?id=17904 Bug ID: 17904 Summary: "Cannot access memory at address 0x0" for function returning reference evaluated within EVAL_AVOID_SIDE_EFFECTS Product: gdb Version: HEAD Status: NEW Severity: normal Priority: P2 Component: exp Assignee: unassigned at sourceware dot org Reporter: ed at catmur dot co.uk Given a function returning a reference: int& g() { static int i; return i; } Evaluating the function within a EVAL_AVOID_SIDE_EFFECTS context gives an error: (gdb) p 0 || +g() Cannot access memory at address 0x0 A workaround is to convert the reference to a pointer and indirect it: (gdb) p 0 || +*&g() $1 = true This appears to be because OP_FUNCALL with EVAL_AVOID_SIDE_EFFECTS calls allocate_value(), which for reference types returns a value with location.address = 0; promotion on the reference argument then calls coerce_ref() which gives a lazy value pointing to 0x0. I'm not sure of a fix other than going through evaluate_subexp_standard() putting in checks for noside == EVAL_AVOID_SIDE_EFFECTS. -- You are receiving this mail because: You are on the CC list for the bug.