Re: [C++ RFC / Patch] PR 54080, PR 52875 and more (aka SFINAE vs template recursion depth)

2013-08-09 Thread Paolo Carlini


Hi,

Yes, that is intended.  Changing that could mean that the meaning of
code depends on what max depth the user selected.

Indeed. Yesterday I wondered what would happen if the front-end had a way to 
detect, in some very specific and special cases only of course, really infinite 
recursions, in the sense that no increase in the depth would cure them. Would 
it be ok in that case to sfinae away?

Paolo



Re: [C++ RFC / Patch] PR 54080, PR 52875 and more (aka SFINAE vs template recursion depth)

2013-08-09 Thread Paolo Carlini
.. another thought I had, less esoteric ;) is the following: we use 
tf_none for two rather different reasons: for SFINAE and to avoid 
recursive Error routines calls, when we call tsubst (... tf_none, ...) 
from dump_template_bindings.


I understand, given your reply, that in general in the first case, thus 
SFINAE, we should avoid all hard errors *but* the one about too deep 
recursions (barring some sort of powerful infinite recursion detector). 
What about the second case, however? Should it be different? An error 
message is being produced in any case, for a reason or another, it 
shouldn't be prevented or made more difficult only because there is deep 
recursion somewhere. I think that in that second case we should suppress 
the error message about too deep recursion too. But how to tell it 
apart? Looks like we want some sort of separate tf_*, a 
tf_in_diagnostic, or something, very similar to tf_none, but truly with 
no exceptions. Actually this vague idea occured to me a number of times, 
I think having that would help in a number of situations.


What do you think?

Thanks,
Paolo.

(*) Maybe there is third one, like in some recent tweaks Jakub did, but 
let's leave it alone here.


Re: [C++ RFC / Patch] PR 54080, PR 52875 and more (aka SFINAE vs template recursion depth)

2013-08-09 Thread Florian Weimer

On 08/09/2013 08:43 AM, Paolo Carlini wrote:


Yes, that is intended.  Changing that could mean that the meaning of
code depends on what max depth the user selected.


Indeed. Yesterday I wondered what would happen if the front-end had a way to detect, in 
some very specific and special cases only of course, really infinite recursions, in the 
sense that no increase in the depth would cure them. Would it be ok in that 
case to sfinae away?


Eh, hopefully not.  Otherwise, program behavior would depend on how well 
the compiler solves the halting problem.


It's interesting question, but hopefully we can make all errors due to 
exceeded implementation limits hard errors, not subject to SFINAE.


--
Florian Weimer / Red Hat Product Security Team


Re: [C++ RFC / Patch] PR 54080, PR 52875 and more (aka SFINAE vs template recursion depth)

2013-08-09 Thread Paolo Carlini


Hi,

Florian Weimer fwei...@redhat.com ha scritto:
On 08/09/2013 08:43 AM, Paolo Carlini wrote:

 Yes, that is intended.  Changing that could mean that the meaning of
 code depends on what max depth the user selected.

 Indeed. Yesterday I wondered what would happen if the front-end had a
way to detect, in some very specific and special cases only of course,
really infinite recursions, in the sense that no increase in the depth
would cure them. Would it be ok in that case to sfinae away?

Eh, hopefully not.  Otherwise, program behavior would depend on how
well
the compiler solves the halting problem.

I see. You know, I was trying to figure out the logic other compilers - two of 
them, actually - are following, because the really appear to sfinae away 
infinite recursions. Was trying to imagine cases in which it would be safe.

Paolo


Re: [C++ RFC / Patch] PR 54080, PR 52875 and more (aka SFINAE vs template recursion depth)

2013-08-09 Thread Florian Weimer

On 08/09/2013 09:28 AM, Paolo Carlini wrote:


I see. You know, I was trying to figure out the logic other compilers - two of 
them, actually - are following, because the really appear to sfinae away 
infinite recursions. Was trying to imagine cases in which it would be safe.


Could their behavior just be bugs?  Depending on their error recovery 
implementation, not flagging infinite recursion as a hard error in 
SFINAE context could be an easy mistake to make.


--
Florian Weimer / Red Hat Product Security Team


Re: [C++ RFC / Patch] PR 54080, PR 52875 and more (aka SFINAE vs template recursion depth)

2013-08-09 Thread Paolo Carlini


Hi,

Florian Weimer fwei...@redhat.com ha scritto:
Could their behavior just be bugs?  Depending on their error recovery
implementation, not flagging infinite recursion as a hard error in
SFINAE context could be an easy mistake to make.

Sure can be. In a sense, as I tried to explain in another sub-thread, we do 
have the complementary one.

Paolo



Re: [C++ RFC / Patch] PR 54080, PR 52875 and more (aka SFINAE vs template recursion depth)

2013-08-09 Thread Gabriel Dos Reis
On Thu, Aug 8, 2013 at 6:40 PM, Jason Merrill ja...@redhat.com wrote:
 On 08/08/2013 03:54 PM, Paolo Carlini wrote:

 the really interesting one is decltype28.C, which we don't reject
 anymore, we simply accept it. What is happening is that the overload
 which leads to excessive template instantiation depth is SFINAE-ed away
 and the other one wins! Thus, this is the core of my message: it seems
 that we behave wrt this issue - SFINAE vs template instantiation depth -
 in a different way vs current clang++ and icc: we produce hard error
 messages in SFINAE contexts. Is that intended?


 Yes, that is intended.  Changing that could mean that the meaning of code
 depends on what max depth the user selected.

that would be disturbing…

-- gaby


Re: [C++ RFC / Patch] PR 54080, PR 52875 and more (aka SFINAE vs template recursion depth)

2013-08-09 Thread Gabriel Dos Reis
On Fri, Aug 9, 2013 at 2:13 AM, Florian Weimer fwei...@redhat.com wrote:
 On 08/09/2013 08:43 AM, Paolo Carlini wrote:

 Yes, that is intended.  Changing that could mean that the meaning of
 code depends on what max depth the user selected.


 Indeed. Yesterday I wondered what would happen if the front-end had a way
 to detect, in some very specific and special cases only of course, really
 infinite recursions, in the sense that no increase in the depth would cure
 them. Would it be ok in that case to sfinae away?


 Eh, hopefully not.  Otherwise, program behavior would depend on how well the
 compiler solves the halting problem.

 It's interesting question, but hopefully we can make all errors due to
 exceeded implementation limits hard errors, not subject to SFINAE.

agreed.

-- Gaby


Re: [C++ RFC / Patch] PR 54080, PR 52875 and more (aka SFINAE vs template recursion depth)

2013-08-09 Thread Gabriel Dos Reis
On Fri, Aug 9, 2013 at 2:33 AM, Florian Weimer fwei...@redhat.com wrote:
 On 08/09/2013 09:28 AM, Paolo Carlini wrote:

 I see. You know, I was trying to figure out the logic other compilers -
 two of them, actually - are following, because the really appear to sfinae
 away infinite recursions. Was trying to imagine cases in which it would be
 safe.


 Could their behavior just be bugs?  Depending on their error recovery
 implementation, not flagging infinite recursion as a hard error in SFINAE
 context could be an easy mistake to make.

Indeed.  The fact we try to recreate template instantiations,
as opposed to using what is already known at the point where
we get the diagnostics is a worrisome aspect of our current
infrastructure.  That obviously manifests itself with the error re-entered…
stuff.

-- Gaby


Re: [C++ RFC / Patch] PR 54080, PR 52875 and more (aka SFINAE vs template recursion depth)

2013-08-09 Thread Gabriel Dos Reis
On Fri, Aug 9, 2013 at 2:13 AM, Paolo Carlini paolo.carl...@oracle.com wrote:
 .. another thought I had, less esoteric ;) is the following: we use tf_none
 for two rather different reasons: for SFINAE and to avoid recursive Error
 routines calls, when we call tsubst (... tf_none, ...) from
 dump_template_bindings.

 I understand, given your reply, that in general in the first case, thus
 SFINAE, we should avoid all hard errors *but* the one about too deep
 recursions (barring some sort of powerful infinite recursion detector). What
 about the second case, however? Should it be different? An error message is
 being produced in any case, for a reason or another, it shouldn't be
 prevented or made more difficult only because there is deep recursion
 somewhere. I think that in that second case we should suppress the error
 message about too deep recursion too. But how to tell it apart? Looks like
 we want some sort of separate tf_*, a tf_in_diagnostic, or something, very
 similar to tf_none, but truly with no exceptions. Actually this vague idea
 occured to me a number of times, I think having that would help in a number
 of situations.

 What do you think?

 Thanks,
 Paolo.

 (*) Maybe there is third one, like in some recent tweaks Jakub did, but
 let's leave it alone here.

I think we should find ways to have the pretty printer in the
diagnostic framework stop trying to redo most of the work
done by the type checker.  In its current form, that is fragile.

-- Gaby


Re: [C++ RFC / Patch] PR 54080, PR 52875 and more (aka SFINAE vs template recursion depth)

2013-08-09 Thread Paolo Carlini

Hi,

On 08/09/2013 10:46 AM, Gabriel Dos Reis wrote:
I think we should find ways to have the pretty printer in the 
diagnostic framework stop trying to redo most of the work done by the 
type checker. In its current form, that is fragile. -- Gaby 
Yeah. That tsubst (..., tf_none, ...) from dump_template_bindings, 
always seemed a little weird to me. Fact is, we have got quite a few 
serious diagnostic bugs where we print *very little* sensible before the 
Error reporting routines re-entered message. Like 54080 and 52875, but 
I'm sure there are more.


Do you have any tips about a reasonable way to handle the latter in the 
short term?


Thanks!
Paolo.


Re: [C++ RFC / Patch] PR 54080, PR 52875 and more (aka SFINAE vs template recursion depth)

2013-08-09 Thread Gabriel Dos Reis
On Fri, Aug 9, 2013 at 4:28 AM, Paolo Carlini paolo.carl...@oracle.com wrote:
 Hi,


 On 08/09/2013 10:46 AM, Gabriel Dos Reis wrote:

 I think we should find ways to have the pretty printer in the diagnostic
 framework stop trying to redo most of the work done by the type checker. In
 its current form, that is fragile. -- Gaby

 Yeah. That tsubst (..., tf_none, ...) from dump_template_bindings, always
 seemed a little weird to me. Fact is, we have got quite a few serious
 diagnostic bugs where we print *very little* sensible before the Error
 reporting routines re-entered message. Like 54080 and 52875, but I'm sure
 there are more.

 Do you have any tips about a reasonable way to handle the latter in the
 short term?

I arrived on the west coast with little sleep, and I can't find sleep just right
now (and you may argue reading gcc list isn't a good way to find sleep
either); let
me think about it more.

-- Gaby


Re: [C++ RFC / Patch] PR 54080, PR 52875 and more (aka SFINAE vs template recursion depth)

2013-08-08 Thread Jason Merrill

On 08/08/2013 03:54 PM, Paolo Carlini wrote:

the really interesting one is decltype28.C, which we don't reject
anymore, we simply accept it. What is happening is that the overload
which leads to excessive template instantiation depth is SFINAE-ed away
and the other one wins! Thus, this is the core of my message: it seems
that we behave wrt this issue - SFINAE vs template instantiation depth -
in a different way vs current clang++ and icc: we produce hard error
messages in SFINAE contexts. Is that intended?


Yes, that is intended.  Changing that could mean that the meaning of 
code depends on what max depth the user selected.


Jason