public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/52363] New: Presence/absence of -pedantic compilation affects run-time behavior
@ 2012-02-23 18:46 wb at fnal dot gov
2012-02-23 19:26 ` [Bug c++/52363] " redi at gcc dot gnu.org
` (13 more replies)
0 siblings, 14 replies; 15+ messages in thread
From: wb at fnal dot gov @ 2012-02-23 18:46 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52363
Bug #: 52363
Summary: Presence/absence of -pedantic compilation affects
run-time behavior
Classification: Unclassified
Product: gcc
Version: 4.7.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: wb@fnal.gov
Created attachment 26738
--> http://gcc.gnu.org/bugzilla/attachment.cgi?id=26738
C++11 source program whose behavior differs w/ -pedantic.
The run-time behavior of the attached C++11 program differs according to the
presence or absence of -pedantic during compilation.
MacPorts compiler version: g++-mp-4.7 (GCC) 4.7.0 20120218 (experimental)
System: MacBook Pro with 2.8GHz Intel Core 2 Duo running OS X 10.6.8
Command line 1: g++-mp-4.7 -O3 -std=c++0x pedantic_t.cc
Command line 2: g++-mp-4.7 -O3 -std=c++0x -pedantic pedantic_t.cc
* Using command line 1, the program builds with no diagnostic and runs to
successful completion.
* Using command line 2, the program builds with no diagnostic, but the
assertion fails during execution.
The principal concern is the inconsistent run-time behavior.
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug c++/52363] Presence/absence of -pedantic compilation affects run-time behavior
2012-02-23 18:46 [Bug c++/52363] New: Presence/absence of -pedantic compilation affects run-time behavior wb at fnal dot gov
@ 2012-02-23 19:26 ` redi at gcc dot gnu.org
2012-04-18 11:05 ` paolo.carlini at oracle dot com
` (12 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: redi at gcc dot gnu.org @ 2012-02-23 19:26 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52363
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Last reconfirmed| |2012-02-23
Ever Confirmed|0 |1
--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> 2012-02-23 19:08:28 UTC ---
confirmed
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug c++/52363] Presence/absence of -pedantic compilation affects run-time behavior
2012-02-23 18:46 [Bug c++/52363] New: Presence/absence of -pedantic compilation affects run-time behavior wb at fnal dot gov
2012-02-23 19:26 ` [Bug c++/52363] " redi at gcc dot gnu.org
@ 2012-04-18 11:05 ` paolo.carlini at oracle dot com
2012-04-18 12:53 ` paolo.carlini at oracle dot com
` (11 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: paolo.carlini at oracle dot com @ 2012-04-18 11:05 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52363
Paolo Carlini <paolo.carlini at oracle dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |jason at gcc dot gnu.org
--- Comment #2 from Paolo Carlini <paolo.carlini at oracle dot com> 2012-04-18 11:03:18 UTC ---
Jason, this is the -pedantic issue I was referring too.
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug c++/52363] Presence/absence of -pedantic compilation affects run-time behavior
2012-02-23 18:46 [Bug c++/52363] New: Presence/absence of -pedantic compilation affects run-time behavior wb at fnal dot gov
2012-02-23 19:26 ` [Bug c++/52363] " redi at gcc dot gnu.org
2012-04-18 11:05 ` paolo.carlini at oracle dot com
@ 2012-04-18 12:53 ` paolo.carlini at oracle dot com
2012-04-18 13:28 ` paolo.carlini at oracle dot com
` (10 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: paolo.carlini at oracle dot com @ 2012-04-18 12:53 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52363
--- Comment #3 from Paolo Carlini <paolo.carlini at oracle dot com> 2012-04-18 12:52:04 UTC ---
Interestingly, removing the const from the move assignment avoids the issue
with -pedantic.
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug c++/52363] Presence/absence of -pedantic compilation affects run-time behavior
2012-02-23 18:46 [Bug c++/52363] New: Presence/absence of -pedantic compilation affects run-time behavior wb at fnal dot gov
` (2 preceding siblings ...)
2012-04-18 12:53 ` paolo.carlini at oracle dot com
@ 2012-04-18 13:28 ` paolo.carlini at oracle dot com
2012-04-18 13:59 ` paolo.carlini at oracle dot com
` (9 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: paolo.carlini at oracle dot com @ 2012-04-18 13:28 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52363
--- Comment #4 from Paolo Carlini <paolo.carlini at oracle dot com> 2012-04-18 13:01:37 UTC ---
And this is enough to see the inconsistency vs -pedantic:
#include <type_traits>
#include <cassert>
struct proxy
{
void operator=(int const&);
void operator=(int &&) const;
};
int main()
{
assert( (std::is_assignable<proxy, int>::value) );
}
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug c++/52363] Presence/absence of -pedantic compilation affects run-time behavior
2012-02-23 18:46 [Bug c++/52363] New: Presence/absence of -pedantic compilation affects run-time behavior wb at fnal dot gov
` (3 preceding siblings ...)
2012-04-18 13:28 ` paolo.carlini at oracle dot com
@ 2012-04-18 13:59 ` paolo.carlini at oracle dot com
2012-04-18 14:11 ` paolo.carlini at oracle dot com
` (8 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: paolo.carlini at oracle dot com @ 2012-04-18 13:59 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52363
Paolo Carlini <paolo.carlini at oracle dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |paolo.carlini at oracle dot
| |com
--- Comment #6 from Paolo Carlini <paolo.carlini at oracle dot com> 2012-04-18 13:56:23 UTC ---
This block of code in joust changes the behavior without -pedantic:
Index: call.c
===================================================================
--- call.c (revision 186565)
+++ call.c (working copy)
@@ -8305,7 +8305,7 @@ tweak:
/* Extension: If the worst conversion for one candidate is worse than the
worst conversion for the other, take the first. */
- if (!pedantic)
+ if (0 && !pedantic)
{
conversion_rank rank1 = cr_identity, rank2 = cr_identity;
struct z_candidate *w = 0, *l = 0;
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug c++/52363] Presence/absence of -pedantic compilation affects run-time behavior
2012-02-23 18:46 [Bug c++/52363] New: Presence/absence of -pedantic compilation affects run-time behavior wb at fnal dot gov
` (4 preceding siblings ...)
2012-04-18 13:59 ` paolo.carlini at oracle dot com
@ 2012-04-18 14:11 ` paolo.carlini at oracle dot com
2012-04-18 14:18 ` paolo.carlini at oracle dot com
` (7 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: paolo.carlini at oracle dot com @ 2012-04-18 14:11 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52363
Paolo Carlini <paolo.carlini at oracle dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |daniel.kruegler at
| |googlemail dot com
--- Comment #7 from Paolo Carlini <paolo.carlini at oracle dot com> 2012-04-18 14:08:45 UTC ---
Daniel, can you have a look to snippet in Comment #5? Should it compile or not?
Because, if it should not, then it seems we should simply arrange for joust to
know about sfinae-mode and in that case behave as-if pedantic were always set.
Would be doable, I think. On the other hand, if it should compile, things
seems a bit more fuzzy to me, it's as if the behavior due to the piece of code
at the end of joust is what we really want, even in -pedantic mode?!?
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug c++/52363] Presence/absence of -pedantic compilation affects run-time behavior
2012-02-23 18:46 [Bug c++/52363] New: Presence/absence of -pedantic compilation affects run-time behavior wb at fnal dot gov
` (5 preceding siblings ...)
2012-04-18 14:11 ` paolo.carlini at oracle dot com
@ 2012-04-18 14:18 ` paolo.carlini at oracle dot com
2012-04-18 14:45 ` daniel.kruegler at googlemail dot com
` (6 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: paolo.carlini at oracle dot com @ 2012-04-18 14:18 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52363
--- Comment #5 from Paolo Carlini <paolo.carlini at oracle dot com> 2012-04-18 13:29:10 UTC ---
Oh, and isn't really a run-time issue:
#include <type_traits>
struct proxy
{
void operator=(int const&);
void operator=(int &&) const;
};
static_assert( std::is_assignable<proxy, int>::value, "" );
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug c++/52363] Presence/absence of -pedantic compilation affects run-time behavior
2012-02-23 18:46 [Bug c++/52363] New: Presence/absence of -pedantic compilation affects run-time behavior wb at fnal dot gov
` (6 preceding siblings ...)
2012-04-18 14:18 ` paolo.carlini at oracle dot com
@ 2012-04-18 14:45 ` daniel.kruegler at googlemail dot com
2012-04-18 14:59 ` paolo.carlini at oracle dot com
` (5 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: daniel.kruegler at googlemail dot com @ 2012-04-18 14:45 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52363
--- Comment #8 from Daniel Krügler <daniel.kruegler at googlemail dot com> 2012-04-18 14:41:38 UTC ---
(In reply to comment #7)
> Daniel, can you have a look to snippet in Comment #5? Should it compile or not?
It needed a while until I recognized that the second operator= overload is a
const function: With this fact my *tentative* interpretation is that the static
assertion should fire, because we have a non-const proxy rvalue and a non-const
int rvalue. The non-const proxy argument has a better match with the non-const
object parameter of the first function, but the int rvalue has a better match
with the int&& argument of the second function. The corresponding C++03 problem
would be described by
struct proxy
{
void operator=(int const&);
void operator=(int &) const;
};
template<class T>
T& create();
int v = sizeof(create<proxy>() = create<int>(), 0);
and is ambiguous as well. The alternative fix (instead of removing the const
from the function) is to *add* a const to left hand type (i.e. use "const
proxy" instead).
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug c++/52363] Presence/absence of -pedantic compilation affects run-time behavior
2012-02-23 18:46 [Bug c++/52363] New: Presence/absence of -pedantic compilation affects run-time behavior wb at fnal dot gov
` (7 preceding siblings ...)
2012-04-18 14:45 ` daniel.kruegler at googlemail dot com
@ 2012-04-18 14:59 ` paolo.carlini at oracle dot com
2012-04-18 15:16 ` jason at gcc dot gnu.org
` (4 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: paolo.carlini at oracle dot com @ 2012-04-18 14:59 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52363
--- Comment #9 from Paolo Carlini <paolo.carlini at oracle dot com> 2012-04-18 14:59:02 UTC ---
Ah, thanks Daniel. Therefore the situation is becoming more clear.
Then - assuming this interpretation is correct - I'm not sure what we want to
do from a practical point of view: should we arrange the front-end to always
have the static_assertion triggered (thus, even without -pedantic) or we really
want that only when -pedantic is passed? I'm not clear whether the user may
like to see the value is std::is_assignable changing depending on -pedantic?!?
I never pondered that possibility in the past.
I guess Jason should give a direction, here.
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug c++/52363] Presence/absence of -pedantic compilation affects run-time behavior
2012-02-23 18:46 [Bug c++/52363] New: Presence/absence of -pedantic compilation affects run-time behavior wb at fnal dot gov
` (8 preceding siblings ...)
2012-04-18 14:59 ` paolo.carlini at oracle dot com
@ 2012-04-18 15:16 ` jason at gcc dot gnu.org
2012-04-18 15:23 ` paolo.carlini at oracle dot com
` (3 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: jason at gcc dot gnu.org @ 2012-04-18 15:16 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52363
--- Comment #10 from Jason Merrill <jason at gcc dot gnu.org> 2012-04-18 15:14:58 UTC ---
std::is_assignable uses SFINAE, so it should always act pedantic, and the
assert should fail.
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug c++/52363] Presence/absence of -pedantic compilation affects run-time behavior
2012-02-23 18:46 [Bug c++/52363] New: Presence/absence of -pedantic compilation affects run-time behavior wb at fnal dot gov
` (9 preceding siblings ...)
2012-04-18 15:16 ` jason at gcc dot gnu.org
@ 2012-04-18 15:23 ` paolo.carlini at oracle dot com
2012-04-24 16:26 ` paolo at gcc dot gnu.org
` (2 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: paolo.carlini at oracle dot com @ 2012-04-18 15:23 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52363
Paolo Carlini <paolo.carlini at oracle dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |ASSIGNED
CC|paolo.carlini at oracle dot |
|com |
AssignedTo|unassigned at gcc dot |paolo.carlini at oracle dot
|gnu.org |com
--- Comment #11 from Paolo Carlini <paolo.carlini at oracle dot com> 2012-04-18 15:20:57 UTC ---
Good. Then, let's see if my idea of tweaking joust to know about sfinae works.
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug c++/52363] Presence/absence of -pedantic compilation affects run-time behavior
2012-02-23 18:46 [Bug c++/52363] New: Presence/absence of -pedantic compilation affects run-time behavior wb at fnal dot gov
` (10 preceding siblings ...)
2012-04-18 15:23 ` paolo.carlini at oracle dot com
@ 2012-04-24 16:26 ` paolo at gcc dot gnu.org
2012-04-24 16:28 ` paolo.carlini at oracle dot com
2012-06-08 0:48 ` paolo.carlini at oracle dot com
13 siblings, 0 replies; 15+ messages in thread
From: paolo at gcc dot gnu.org @ 2012-04-24 16:26 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52363
--- Comment #12 from paolo at gcc dot gnu.org <paolo at gcc dot gnu.org> 2012-04-24 16:25:33 UTC ---
Author: paolo
Date: Tue Apr 24 16:25:15 2012
New Revision: 186774
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=186774
Log:
/cp
2012-04-24 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/52363
* call.c (tourney, perform_overload_resolution,
build_operator_new_call, build_user_type_conversion_1,
build_user_type_conversion, perform_overload_resolution,
add_template_candidate, add_template_candidate_real,
add_template_conv_candidate, add_builtin_candidates,
add_builtin_candidate, build_builtin_candidate,
add_conv_candidate, add_function_candidate, implicit_conversion,
reference_binding, build_list_conv, conditional_conversion,
add_candidates, can_convert_array, build_aggr_conv,
build_array_conv, build_complex_conv, conditional_conversion):
Add tsubst_flags_t parameter.
(joust): Likewise, use it to handle SFINAE as if pedantic.
(add_list_candidates, build_integral_nontype_arg_conv,
perform_overload_resolution, build_new_function_call,
build_operator_new_call, build_op_call_1,
build_conditional_expr_1, build_new_op_1, convert_like_real,
convert_arg_to_ellipsis, convert_default_arg,
convert_for_arg_passing, build_over_call,
build_new_method_call_1, can_convert_arg, can_convert_arg_bad,
perform_implicit_conversion_flags,
perform_direct_initialization_if_possible,
initialize_reference): Adjust.
* typeck.c (casts_away_constness, casts_away_constness_r):
Add tsubst_flags_t parameter.
(convert_arguments, check_for_casting_away_constness,
build_static_cast_1, build_ptrmemfunc, convert_for_assignment):
Adjust.
* decl.c (reshape_init_r, check_default_argument): Likewise.
* cp-gimplify.c (cxx_omp_clause_apply_fn): Likewise.
* pt.c (convert_nontype_argument, check_non_deducible_conversion):
Likewise.
* init.c (build_new_1): Likewise.
* cvt.c (convert_to_reference, ocp_convert, build_type_conversion,
build_expr_type_conversion, ): Likewise.
* search.c (check_final_overrider): Likewise.
* cp-tree.h (build_user_type_conversion,
build_operator_new_call, can_convert, can_convert_arg,
can_convert_arg_bad, convert_default_arg,
convert_arg_to_ellipsis, convert_for_arg_passing):
Adjust declaration.
/testsuite
2012-04-24 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/52363
* g++.dg/cpp0x/sfinae35.C: New.
* g++.dg/cpp0x/sfinae36.C: Likewise.
Added:
trunk/gcc/testsuite/g++.dg/cpp0x/sfinae35.C
trunk/gcc/testsuite/g++.dg/cpp0x/sfinae36.C
Modified:
trunk/gcc/cp/ChangeLog
trunk/gcc/cp/call.c
trunk/gcc/cp/cp-gimplify.c
trunk/gcc/cp/cp-tree.h
trunk/gcc/cp/cvt.c
trunk/gcc/cp/decl.c
trunk/gcc/cp/init.c
trunk/gcc/cp/pt.c
trunk/gcc/cp/search.c
trunk/gcc/cp/typeck.c
trunk/gcc/testsuite/ChangeLog
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug c++/52363] Presence/absence of -pedantic compilation affects run-time behavior
2012-02-23 18:46 [Bug c++/52363] New: Presence/absence of -pedantic compilation affects run-time behavior wb at fnal dot gov
` (11 preceding siblings ...)
2012-04-24 16:26 ` paolo at gcc dot gnu.org
@ 2012-04-24 16:28 ` paolo.carlini at oracle dot com
2012-06-08 0:48 ` paolo.carlini at oracle dot com
13 siblings, 0 replies; 15+ messages in thread
From: paolo.carlini at oracle dot com @ 2012-04-24 16:28 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52363
Paolo Carlini <paolo.carlini at oracle dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Resolution| |FIXED
Target Milestone|--- |4.8.0
--- Comment #13 from Paolo Carlini <paolo.carlini at oracle dot com> 2012-04-24 16:27:58 UTC ---
Fixed for 4.8.0.
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug c++/52363] Presence/absence of -pedantic compilation affects run-time behavior
2012-02-23 18:46 [Bug c++/52363] New: Presence/absence of -pedantic compilation affects run-time behavior wb at fnal dot gov
` (12 preceding siblings ...)
2012-04-24 16:28 ` paolo.carlini at oracle dot com
@ 2012-06-08 0:48 ` paolo.carlini at oracle dot com
13 siblings, 0 replies; 15+ messages in thread
From: paolo.carlini at oracle dot com @ 2012-06-08 0:48 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52363
Paolo Carlini <paolo.carlini at oracle dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |hstong at ca dot ibm.com
--- Comment #14 from Paolo Carlini <paolo.carlini at oracle dot com> 2012-06-08 00:47:47 UTC ---
*** Bug 53606 has been marked as a duplicate of this bug. ***
^ permalink raw reply [flat|nested] 15+ messages in thread
end of thread, other threads:[~2012-06-08 0:48 UTC | newest]
Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-02-23 18:46 [Bug c++/52363] New: Presence/absence of -pedantic compilation affects run-time behavior wb at fnal dot gov
2012-02-23 19:26 ` [Bug c++/52363] " redi at gcc dot gnu.org
2012-04-18 11:05 ` paolo.carlini at oracle dot com
2012-04-18 12:53 ` paolo.carlini at oracle dot com
2012-04-18 13:28 ` paolo.carlini at oracle dot com
2012-04-18 13:59 ` paolo.carlini at oracle dot com
2012-04-18 14:11 ` paolo.carlini at oracle dot com
2012-04-18 14:18 ` paolo.carlini at oracle dot com
2012-04-18 14:45 ` daniel.kruegler at googlemail dot com
2012-04-18 14:59 ` paolo.carlini at oracle dot com
2012-04-18 15:16 ` jason at gcc dot gnu.org
2012-04-18 15:23 ` paolo.carlini at oracle dot com
2012-04-24 16:26 ` paolo at gcc dot gnu.org
2012-04-24 16:28 ` paolo.carlini at oracle dot com
2012-06-08 0:48 ` 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).