Boost logo

Boost Users :

From: Martin Apel (martin.apel_at_[hidden])
Date: 2008-06-17 05:23:21


Joel de Guzman wrote:
> Martin Apel wrote:
>
>
>> boost/spirit/phoenix/closures.hpp closure<..>::context() is declared to
>> return a reference to a closure_frame_t, which is a closure_frame<self_t>.
>> The implementation consists of frame.get(), which invokes the get method
>> on holder_t, which is a closure_frame_holder<closure_frame_t>. When
>> looking at the get method of closure_frame_holder, it
>> returns a reference to frame_ptr, which is a frame_t*, which is not the
>> same as an object of type closure_frame<self_t> as declared by
>> closure<...>::context()
>>
>
> :-) I think you missed the #ifdef PHOENIX_THREADSAFE branch.
>
>
I don't think so. See the following small test function, which does not
do anything sensible, but from my understanding it should at least compile:
void test(void)
{
   closure<int> c;

   closure<int>::closure_frame_t& frame = c.context();
}

But it doesn't compile, even with gcc. The error is either (without
NDEBUG defined):
/scratch/apel/boost_install/linux32/include/boost-1_35/boost/spirit/phoenix/closures.hpp:
In member function 'phoenix::closure_frame<phoenix::closure<T0, T1, T2>
>& phoenix::closure<T0, T1, T2>::context() [with T0 = int, T1 =
phoenix::nil_t, T2 = phoenix::nil_t]':
test2.cpp:9: instantiated from here
/scratch/apel/boost_install/linux32/include/boost-1_35/boost/spirit/phoenix/closures.hpp:352:
error: no match for 'operator!=' in '((phoenix::closure<int,
phoenix::nil_t, phoenix::nil_t>*)this)->phoenix::closure<int,
phoenix::nil_t, phoenix::nil_t>::frame != 0'
test2.cpp:9: instantiated from here
/scratch/apel/boost_install/linux32/include/boost-1_35/boost/spirit/phoenix/closures.hpp:352:
error: invalid initialization of reference of type
'phoenix::closure_frame<phoenix::closure<int, phoenix::nil_t,
phoenix::nil_t> >&' from expression of type
'phoenix::closure_frame<phoenix::closure<int, phoenix::nil_t,
phoenix::nil_t> >*'

or (with NDEBUG defined):
/scratch/apel/boost_install/linux32/include/boost-1_35/boost/spirit/phoenix/closures.hpp:
In member function 'phoenix::closure_frame<phoenix::closure<T0, T1, T2>
>& phoenix::closure<T0, T1, T2>::context() [with T0 = int, T1 =
phoenix::nil_t, T2 = phoenix::nil_t]':
test2.cpp:9: instantiated from here
/scratch/apel/boost_install/linux32/include/boost-1_35/boost/spirit/phoenix/closures.hpp:352:
error: invalid initialization of reference of type
'phoenix::closure_frame<phoenix::closure<int, phoenix::nil_t,
phoenix::nil_t> >&' from expression of type
'phoenix::closure_frame<phoenix::closure<int, phoenix::nil_t,
phoenix::nil_t> >*'

Can you reproduce this?
>> Sorry, it wasn't meant as an accusation.
>>
>
> Nah, just kidding. That's why there was a smiley there ;-)
>
> I had found this out some
>
>> months ago, so I tried to give an example from my memory. I didn't
>> expect Spirit to behave exactly as iostream, because there was no
>> specification with respect to numerical accuracy. Additionally I only
>> found this out, when setting the precision to 20, 15 is not enough. I
>> played around a bit, to find an example:
>>
>
> I'd appreciate it if you can add a bug report to Boost's trac.
> Let's see if we can do better. Thanks for reporting this!
>
>
I added a bug report to Trac. It's got the number 2014.

Regards,

Martin


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net