public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/64877] New: strange warning message from -Waddress
@ 2015-01-30 16:56 tromey at gcc dot gnu.org
2015-01-30 18:16 ` [Bug c++/64877] " manu at gcc dot gnu.org
` (5 more replies)
0 siblings, 6 replies; 7+ messages in thread
From: tromey at gcc dot gnu.org @ 2015-01-30 16:56 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64877
Bug ID: 64877
Summary: strange warning message from -Waddress
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: tromey at gcc dot gnu.org
I found a spot in firefox that tries to prevent hiding
using:
explicit ScopedGLWrapper(GLContext* gl)
: mIsUnwrapped(false)
, mGL(gl)
{
MOZ_ASSERT(&ScopedGLWrapper<Derived>::Unwrap == &Derived::Unwrap);
[...]
void Unwrap() {
...
}
gcc 5 warns about this assert:
/home/tromey/firefox-git/gecko-dev/gfx/gl/ScopedGLHelpers.h:35:54: error: the
address of ‘void mozilla::gl::ScopedGLWrapper<Derived>::Unwrap() [with Derived
= mozilla::gl::ScopedGLState]’ will never be NULL [-Werror=address]
MOZ_ASSERT(&ScopedGLWrapper<Derived>::Unwrap == &Derived::Unwrap);
^
The message here is strange. Whether or not the address can be NULL
is not an issue. I don't see why -Waddress ought to warn here at all.
>From gcc-bugs-return-475537-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Fri Jan 30 16:58:42 2015
Return-Path: <gcc-bugs-return-475537-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 29662 invoked by alias); 30 Jan 2015 16:58:41 -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 29593 invoked by uid 48); 30 Jan 2015 16:58:35 -0000
From: "tromey at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/20710] g++ should warn when hiding non-virtual method in base class
Date: Fri, 30 Jan 2015 16:58:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: c++
X-Bugzilla-Version: 3.4.3
X-Bugzilla-Keywords: diagnostic
X-Bugzilla-Severity: enhancement
X-Bugzilla-Who: tromey at gcc dot gnu.org
X-Bugzilla-Status: NEW
X-Bugzilla-Priority: P2
X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org
X-Bugzilla-Target-Milestone: ---
X-Bugzilla-Flags:
X-Bugzilla-Changed-Fields: cc
Message-ID: <bug-20710-4-e15QIsjYqH@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-20710-4@http.gcc.gnu.org/bugzilla/>
References: <bug-20710-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: 2015-01/txt/msg03531.txt.bz2
Content-length: 833
https://gcc.gnu.org/bugzilla/show_bug.cgi?id 710
Tom Tromey <tromey at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |tromey at gcc dot gnu.org
--- Comment #8 from Tom Tromey <tromey at gcc dot gnu.org> ---
It would be nice to have a way to prevent hiding.
See the partial example in bug 64877. Here, gcc 5
warns about the construct used to prevent hiding.
However, "final" will not work as the function in question
is non-virtual.
The class in question is a base class, so it seems rather
strange to make the function "virtual final". And, while
not an issue in this particular case, that would in some
cases introduce a vtable where none was previously needed.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/64877] strange warning message from -Waddress
2015-01-30 16:56 [Bug c++/64877] New: strange warning message from -Waddress tromey at gcc dot gnu.org
@ 2015-01-30 18:16 ` manu at gcc dot gnu.org
2015-01-30 18:38 ` tromey at gcc dot gnu.org
` (4 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: manu at gcc dot gnu.org @ 2015-01-30 18:16 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64877
Manuel López-Ibáñez <manu at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |manu at gcc dot gnu.org
--- Comment #1 from Manuel López-Ibáñez <manu at gcc dot gnu.org> ---
(In reply to Tom Tromey from comment #0)
> The message here is strange. Whether or not the address can be NULL
> is not an issue. I don't see why -Waddress ought to warn here at all.
Hard to say without a minimized testcase.
>From gcc-bugs-return-475555-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Fri Jan 30 18:23:24 2015
Return-Path: <gcc-bugs-return-475555-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 12795 invoked by alias); 30 Jan 2015 18:23:24 -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 12537 invoked by uid 48); 30 Jan 2015 18:23:13 -0000
From: "dmalcolm at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug jit/64873] jit testsuite failures on powerpc64le-unknown-linux-gnu
Date: Fri, 30 Jan 2015 18:23:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: jit
X-Bugzilla-Version: 5.0
X-Bugzilla-Keywords:
X-Bugzilla-Severity: normal
X-Bugzilla-Who: dmalcolm at gcc dot gnu.org
X-Bugzilla-Status: RESOLVED
X-Bugzilla-Priority: P3
X-Bugzilla-Assigned-To: dmalcolm at gcc dot gnu.org
X-Bugzilla-Target-Milestone: ---
X-Bugzilla-Flags:
X-Bugzilla-Changed-Fields: bug_status resolution
Message-ID: <bug-64873-4-iXDc2tHP9T@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-64873-4@http.gcc.gnu.org/bugzilla/>
References: <bug-64873-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: 2015-01/txt/msg03549.txt.bz2
Content-length: 1325
https://gcc.gnu.org/bugzilla/show_bug.cgi?idd873
David Malcolm <dmalcolm at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution|--- |DUPLICATE
--- Comment #3 from David Malcolm <dmalcolm at gcc dot gnu.org> ---
(In reply to David Malcolm from comment #2)
> I'll rerun the JIT build and tests, with the correct configuration flags for
> this hardware, and with the candidate patches for PR jit/64810 (so that the
> jit honors them).
Indeed, upon applying the candidate fixes for PR jit/64810 posted to:
https://gcc.gnu.org/ml/gcc-patches/2015-01/msg02704.html
and reconfiguring with:
--with-cpu-64=power7 --with-tune-64=power8
the jit testsuite successfully runs to completion on this "box", with
everything passing (apart from known failure PR jit/64752); injected
options are visible in jit logs as:
configure_time_options[0]: -mtune=power8
configure_time_options[1]: -mcpu=power7
So this was a mixture of configuration error on my part, and a duplicate
of PR jit/64810.
Closing as a duplicate of PR jit/64810; sorry for the noise.
*** This bug has been marked as a duplicate of bug 64810 ***
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/64877] strange warning message from -Waddress
2015-01-30 16:56 [Bug c++/64877] New: strange warning message from -Waddress tromey at gcc dot gnu.org
2015-01-30 18:16 ` [Bug c++/64877] " manu at gcc dot gnu.org
@ 2015-01-30 18:38 ` tromey at gcc dot gnu.org
2015-01-31 16:05 ` manu at gcc dot gnu.org
` (3 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: tromey at gcc dot gnu.org @ 2015-01-30 18:38 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64877
--- Comment #2 from Tom Tromey <tromey at gcc dot gnu.org> ---
(In reply to Manuel López-Ibáñez from comment #1)
> Hard to say without a minimized testcase.
Yeah.
The original code is here:
https://dxr.mozilla.org/mozilla-central/source/gfx/gl/ScopedGLHelpers.h#35
My attempt to minimize it failed.
Here's what I tried. I can't explain why this doesn't
give any warnings as I would expect one on the second "assert",
based on what the manual says.
template<class Derived>
struct S
{
void m() {
}
S()
{
if (&S<Derived>::Unwrap != &Derived::Unwrap)
m();
if (!(&Derived::UnwrapImpl))
m();
}
void Unwrap() {
}
};
struct T : public S<T>
{
void UnwrapImpl() {
}
};
T t;
>From gcc-bugs-return-475558-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Fri Jan 30 18:50:03 2015
Return-Path: <gcc-bugs-return-475558-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 25354 invoked by alias); 30 Jan 2015 18:50:03 -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 25059 invoked by uid 48); 30 Jan 2015 18:49:53 -0000
From: "tromey at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/64877] strange warning message from -Waddress
Date: Fri, 30 Jan 2015 18:50:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: c++
X-Bugzilla-Version: unknown
X-Bugzilla-Keywords:
X-Bugzilla-Severity: normal
X-Bugzilla-Who: tromey 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:
Message-ID: <bug-64877-4-lGSFrc7TO9@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-64877-4@http.gcc.gnu.org/bugzilla/>
References: <bug-64877-4@http.gcc.gnu.org/bugzilla/>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/
Auto-Submitted: auto-generated
MIME-Version: 1.0
X-SW-Source: 2015-01/txt/msg03551.txt.bz2
Content-length: 638
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64877
--- Comment #3 from Tom Tromey <tromey at gcc dot gnu.org> ---
Oops, had the wrong gcc in $PATH.
That test case does warn:
pokyo. g++ -std=c++11 -c -Wall -Waddress -O2 x.cc
x.cc: In instantiation of ‘S<Derived>::S() [with Derived = T]’:
x.cc:19:8: required from here
x.cc:9:29: warning: the address of ‘void S<Derived>::Unwrap() [with Derived =
T]’ will never be NULL [-Waddress]
if (&S<Derived>::Unwrap != &Derived::Unwrap)
^
I think I would expect a warning on the second assert, but not the first.
>From gcc-bugs-return-475557-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Fri Jan 30 18:50:03 2015
Return-Path: <gcc-bugs-return-475557-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 25320 invoked by alias); 30 Jan 2015 18:50:01 -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 25151 invoked by uid 48); 30 Jan 2015 18:49:55 -0000
From: "jakub at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/64867] warning for passing non-POD to varargs function
Date: Fri, 30 Jan 2015 18:50:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: c++
X-Bugzilla-Version: unknown
X-Bugzilla-Keywords:
X-Bugzilla-Severity: normal
X-Bugzilla-Who: jakub 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: cc
Message-ID: <bug-64867-4-PFNVv4Sqm6@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-64867-4@http.gcc.gnu.org/bugzilla/>
References: <bug-64867-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: 2015-01/txt/msg03552.txt.bz2
Content-length: 423
https://gcc.gnu.org/bugzilla/show_bug.cgi?idd867
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |jakub at gcc dot gnu.org
--- Comment #10 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
FYI, g++ stopped warning on #c4 with r149721.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/64877] strange warning message from -Waddress
2015-01-30 16:56 [Bug c++/64877] New: strange warning message from -Waddress tromey at gcc dot gnu.org
2015-01-30 18:16 ` [Bug c++/64877] " manu at gcc dot gnu.org
2015-01-30 18:38 ` tromey at gcc dot gnu.org
@ 2015-01-31 16:05 ` manu at gcc dot gnu.org
2015-01-31 17:38 ` [Bug c++/64877] [5 Regression] " paolo.carlini at oracle dot com
` (2 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: manu at gcc dot gnu.org @ 2015-01-31 16:05 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64877
Manuel López-Ibáñez <manu at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Last reconfirmed| |2015-01-31
CC| |paolo.carlini at oracle dot com
Version|unknown |5.0
Ever confirmed|0 |1
--- Comment #4 from Manuel López-Ibáñez <manu at gcc dot gnu.org> ---
(In reply to Tom Tromey from comment #3)
> Oops, had the wrong gcc in $PATH.
> That test case does warn:
>
> pokyo. g++ -std=c++11 -c -Wall -Waddress -O2 x.cc
> x.cc: In instantiation of ‘S<Derived>::S() [with Derived = T]’:
> x.cc:19:8: required from here
> x.cc:9:29: warning: the address of ‘void S<Derived>::Unwrap() [with Derived
> = T]’ will never be NULL [-Waddress]
> if (&S<Derived>::Unwrap != &Derived::Unwrap)
> ^
>
>
> I think I would expect a warning on the second assert, but not the first.
We hit this code in cp/typeck.c
/* We generate:
(op0.pfn == op1.pfn
&& (!op0.pfn || op0.delta == op1.delta))
The reason for the `!op0.pfn' bit is that a NULL
pointer-to-member is any member with a zero PFN; the
DELTA field is unspecified. */
e1 = cp_build_binary_op (location,
EQ_EXPR, delta0, delta1, complain);
e2 = cp_build_binary_op (location,
EQ_EXPR,
pfn0,
build_zero_cst (TREE_TYPE (pfn0)),
complain);
e1 = cp_build_binary_op (location,
TRUTH_ORIF_EXPR, e1, e2, complain);
thus, the !op0.pfn triggers the warning. It may be enough to pass tf_none
instead of complain for the two compiler-generated expressions. Alternatively,
since we know pfn0 cannot be NULL, do not generate this check. It seems quite
wasteful to go through the huge cp_build_binary_op just to build something that
will get optimized out.
Not working on this, but it seems feasible to fix. If it is a regression, you
may even convince someone to approve it for GCC 5.
>From gcc-bugs-return-475632-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Sat Jan 31 16:09:42 2015
Return-Path: <gcc-bugs-return-475632-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 10634 invoked by alias); 31 Jan 2015 16:09:42 -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 10583 invoked by uid 48); 31 Jan 2015 16:09:37 -0000
From: "manu at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/64877] strange warning message from -Waddress
Date: Sat, 31 Jan 2015 16:09:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: c++
X-Bugzilla-Version: 5.0
X-Bugzilla-Keywords:
X-Bugzilla-Severity: normal
X-Bugzilla-Who: manu at gcc dot gnu.org
X-Bugzilla-Status: NEW
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:
Message-ID: <bug-64877-4-MbRtXqLjx8@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-64877-4@http.gcc.gnu.org/bugzilla/>
References: <bug-64877-4@http.gcc.gnu.org/bugzilla/>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/
Auto-Submitted: auto-generated
MIME-Version: 1.0
X-SW-Source: 2015-01/txt/msg03626.txt.bz2
Content-length: 1298
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64877
--- Comment #5 from Manuel López-Ibáñez <manu at gcc dot gnu.org> ---
And just for the sake of completion, the warning we trigger is:
else if (((code0 == POINTER_TYPE || TYPE_PTRDATAMEM_P (type0))
&& null_ptr_cst_p (op1))
/* Handle, eg, (void*)0 (c++/43906), and more. */
|| (code0 == POINTER_TYPE
&& TYPE_PTR_P (type1) && integer_zerop (op1)))
{
if (TYPE_PTR_P (type1))
result_type = composite_pointer_type (type0, type1, op0, op1,
CPO_COMPARISON, complain);
else
result_type = type0;
if (TREE_CODE (op0) == ADDR_EXPR
B => && decl_with_nonnull_addr_p (TREE_OPERAND (op0, 0)))
{
if ((complain & tf_warning)
&& c_inhibit_evaluation_warnings == 0)
warning (OPT_Waddress, "the address of %qD will never be
NULL",
TREE_OPERAND (op0, 0));
}
}
It could be enough to test decl_with_nonnull_addr_p (TREE_OPERAND (op0, 0)) to
avoid building !op0.pfn when not needed.
>From gcc-bugs-return-475633-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Sat Jan 31 16:14:53 2015
Return-Path: <gcc-bugs-return-475633-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 14253 invoked by alias); 31 Jan 2015 16:14:53 -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 14208 invoked by uid 48); 31 Jan 2015 16:14:49 -0000
From: "paolo.carlini at oracle dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/64791] Generic lambda fails to implicitly capture `const` variable
Date: Sat, 31 Jan 2015 16:14:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: c++
X-Bugzilla-Version: 4.9.2
X-Bugzilla-Keywords: rejects-valid
X-Bugzilla-Severity: normal
X-Bugzilla-Who: paolo.carlini at oracle dot com
X-Bugzilla-Status: NEW
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:
Message-ID: <bug-64791-4-m8y6JpzYMz@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-64791-4@http.gcc.gnu.org/bugzilla/>
References: <bug-64791-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: 2015-01/txt/msg03627.txt.bz2
Content-length: 387
https://gcc.gnu.org/bugzilla/show_bug.cgi?idd791
--- Comment #8 from Paolo Carlini <paolo.carlini at oracle dot com> ---
Weird, I tried on my machine yesterday's r220267 and same result, no warning
(with -std=gnu++1z -Wall -Wextra). I guess that before closing this bug we need
either to figure out what's special about that web page or another report that
things are actually fine.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/64877] [5 Regression] strange warning message from -Waddress
2015-01-30 16:56 [Bug c++/64877] New: strange warning message from -Waddress tromey at gcc dot gnu.org
` (2 preceding siblings ...)
2015-01-31 16:05 ` manu at gcc dot gnu.org
@ 2015-01-31 17:38 ` paolo.carlini at oracle dot com
2015-02-03 17:22 ` paolo at gcc dot gnu.org
2015-02-03 17:23 ` paolo.carlini at oracle dot com
5 siblings, 0 replies; 7+ messages in thread
From: paolo.carlini at oracle dot com @ 2015-01-31 17:38 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64877
Paolo Carlini <paolo.carlini at oracle dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Summary|strange warning message |[5 Regression] strange
|from -Waddress |warning message from
| |-Waddress
--- Comment #6 from Paolo Carlini <paolo.carlini at oracle dot com> ---
Thanks Manuel for the analysis. Indeed, now -Waddress is much more general, and
those internally generated expressions are causing problems. Thus, following
your suggestion, I would propose something like the below, which I'm finishing
testing. Does it look Ok to you?
Index: typeck.c
===================================================================
--- typeck.c (revision 220306)
+++ typeck.c (working copy)
@@ -4552,35 +4552,44 @@ cp_build_binary_op (location_t location,
The reason for the `!op0.pfn' bit is that a NULL
pointer-to-member is any member with a zero PFN and
- LSB of the DELTA field is 0. */
+ LSB of the DELTA field is 0. Note: avoid generating the
+ '|| (!op0.pfn && ...)' if !op0.pfn is known to be false. */
- e1 = cp_build_binary_op (location, BIT_AND_EXPR,
- delta0,
- integer_one_node,
- complain);
- e1 = cp_build_binary_op (location,
- EQ_EXPR, e1, integer_zero_node,
- complain);
- e2 = cp_build_binary_op (location, BIT_AND_EXPR,
- delta1,
- integer_one_node,
- complain);
- e2 = cp_build_binary_op (location,
- EQ_EXPR, e2, integer_zero_node,
- complain);
- e1 = cp_build_binary_op (location,
- TRUTH_ANDIF_EXPR, e2, e1,
- complain);
- e2 = cp_build_binary_op (location, EQ_EXPR,
- pfn0,
- build_zero_cst (TREE_TYPE (pfn0)),
- complain);
- e2 = cp_build_binary_op (location,
- TRUTH_ANDIF_EXPR, e2, e1, complain);
- e1 = cp_build_binary_op (location,
- EQ_EXPR, delta0, delta1, complain);
- e1 = cp_build_binary_op (location,
- TRUTH_ORIF_EXPR, e1, e2, complain);
+ if (TREE_CODE (pfn0) != ADDR_EXPR
+ || !decl_with_nonnull_addr_p (TREE_OPERAND (pfn0, 0)))
+ {
+ e1 = cp_build_binary_op (location, BIT_AND_EXPR,
+ delta0,
+ integer_one_node,
+ complain);
+ e1 = cp_build_binary_op (location,
+ EQ_EXPR, e1, integer_zero_node,
+ complain);
+ e2 = cp_build_binary_op (location, BIT_AND_EXPR,
+ delta1,
+ integer_one_node,
+ complain);
+ e2 = cp_build_binary_op (location,
+ EQ_EXPR, e2, integer_zero_node,
+ complain);
+ e1 = cp_build_binary_op (location,
+ TRUTH_ANDIF_EXPR, e2, e1,
+ complain);
+ e2 = cp_build_binary_op (location, EQ_EXPR,
+ pfn0,
+ build_zero_cst (TREE_TYPE (pfn0)),
+ complain);
+ e2 = cp_build_binary_op (location,
+ TRUTH_ANDIF_EXPR, e2, e1, complain);
+ e1 = cp_build_binary_op (location,
+ EQ_EXPR, delta0, delta1, complain);
+ e1 = cp_build_binary_op (location,
+ TRUTH_ORIF_EXPR, e1, e2, complain);
+
+ }
+ else
+ e1 = cp_build_binary_op (location,
+ EQ_EXPR, delta0, delta1, complain);
}
else
{
@@ -4591,17 +4600,22 @@ cp_build_binary_op (location_t location,
The reason for the `!op0.pfn' bit is that a NULL
pointer-to-member is any member with a zero PFN; the
- DELTA field is unspecified. */
+ DELTA field is unspecified. Note: avoid generating the
+ '!op0.pfn ||' if !op0.pfn is known to be false. */
e1 = cp_build_binary_op (location,
EQ_EXPR, delta0, delta1, complain);
- e2 = cp_build_binary_op (location,
- EQ_EXPR,
- pfn0,
- build_zero_cst (TREE_TYPE (pfn0)),
- complain);
- e1 = cp_build_binary_op (location,
- TRUTH_ORIF_EXPR, e1, e2, complain);
+ if (TREE_CODE (pfn0) != ADDR_EXPR
+ || !decl_with_nonnull_addr_p (TREE_OPERAND (pfn0, 0)))
+ {
+ e2 = cp_build_binary_op (location,
+ EQ_EXPR,
+ pfn0,
+ build_zero_cst (TREE_TYPE (pfn0)),
+ complain);
+ e1 = cp_build_binary_op (location,
+ TRUTH_ORIF_EXPR, e1, e2, complain);
+ }
}
e2 = build2 (EQ_EXPR, boolean_type_node, pfn0, pfn1);
e = cp_build_binary_op (location,
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/64877] [5 Regression] strange warning message from -Waddress
2015-01-30 16:56 [Bug c++/64877] New: strange warning message from -Waddress tromey at gcc dot gnu.org
` (3 preceding siblings ...)
2015-01-31 17:38 ` [Bug c++/64877] [5 Regression] " paolo.carlini at oracle dot com
@ 2015-02-03 17:22 ` paolo at gcc dot gnu.org
2015-02-03 17:23 ` paolo.carlini at oracle dot com
5 siblings, 0 replies; 7+ messages in thread
From: paolo at gcc dot gnu.org @ 2015-02-03 17:22 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64877
--- Comment #7 from paolo at gcc dot gnu.org <paolo at gcc dot gnu.org> ---
Author: paolo
Date: Tue Feb 3 17:21:49 2015
New Revision: 220374
URL: https://gcc.gnu.org/viewcvs?rev=220374&root=gcc&view=rev
Log:
/cp
2015-02-03 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/64877
* typeck.c (cp_build_binary_op): Avoid spurious -Waddress warnings
for generated expressions.
/testsuite
2015-02-03 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/64877
* g++.dg/warn/Waddress-2.C: New.
Added:
trunk/gcc/testsuite/g++.dg/warn/Waddress-2.C
Modified:
trunk/gcc/cp/ChangeLog
trunk/gcc/cp/typeck.c
trunk/gcc/testsuite/ChangeLog
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/64877] [5 Regression] strange warning message from -Waddress
2015-01-30 16:56 [Bug c++/64877] New: strange warning message from -Waddress tromey at gcc dot gnu.org
` (4 preceding siblings ...)
2015-02-03 17:22 ` paolo at gcc dot gnu.org
@ 2015-02-03 17:23 ` paolo.carlini at oracle dot com
5 siblings, 0 replies; 7+ messages in thread
From: paolo.carlini at oracle dot com @ 2015-02-03 17:23 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64877
Paolo Carlini <paolo.carlini at oracle dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
CC|paolo.carlini at oracle dot com |
Resolution|--- |FIXED
Target Milestone|--- |5.0
--- Comment #8 from Paolo Carlini <paolo.carlini at oracle dot com> ---
Fixed.
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2015-02-03 17:23 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-01-30 16:56 [Bug c++/64877] New: strange warning message from -Waddress tromey at gcc dot gnu.org
2015-01-30 18:16 ` [Bug c++/64877] " manu at gcc dot gnu.org
2015-01-30 18:38 ` tromey at gcc dot gnu.org
2015-01-31 16:05 ` manu at gcc dot gnu.org
2015-01-31 17:38 ` [Bug c++/64877] [5 Regression] " paolo.carlini at oracle dot com
2015-02-03 17:22 ` paolo at gcc dot gnu.org
2015-02-03 17:23 ` paolo.carlini at oracle dot com
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).