[aspectc-user] volatile kills args (...) matching
Olaf Spinczyk
os at aspectc.org
Sat Apr 5 11:51:16 CEST 2008
Hi,
I'd like to clarify something about the C++ standard here. The following
function signatures are all considered as semantically equivalent in C++:
void f(int);
void f(const int);
void f(volatile int);
void f(const volatile int);
This is fact relevant for function overloading (which does not work with
these four functions), linking, etc.
Therefore, every C++ compiler including the ac++ weaver normalizes these
signatures. BTW, NOT ALL "const" and "volatile" keywords are removed,
just those on the top level of an argument type. For example, the
signature "void f(const int *)" remains as it is and is not considered
equivalent with "void f(int *)".
Now it should be clear why an AspectC++ match expression "void f(int)"
matches all four functions shown above.
The meaning of "const" and "volatile" in a match expression is
different: It is considered as a restriction. For example, a match
expression "void %(int *)" would match "void f (const int*)" and "void
f(int*)", while "void %(const int*)" ONLY matches "void f(const int*). A
match expression "void f(const %)" does not make sense and will yield no
results, because after normalization no function still has a matching
signature.
I don't want to say with this mail that the behavior of ac++ is correct
and make sense. It's just to explain a few of the effects that you've
observed.
Cheers,
Olaf
arnd-hendrik.mathias at nefkom.net wrote:
> Hi,
> I don't think it is really a bug but depends rather on the way, the
> pointcut handling and the before(), after()...etc. functions work. My
> test application shows following behavior:
>
> - volatile does not influence the matching of pointcuts to the
> functions itself, which means that even
> + a pointcut with a volatile parameter matches a function with
> non-volatile parameter and
> + a pointcut with a non-volatile parameter matches a function with
> volatile parameters.
>
> - using volatile in the parameter list of before ( ... ) etc. causes
> the advice to be silently ignored in any case (no warning, no error
> but no working, too).
>
> - omitting volatile in the parameter list of the before ( ... ) etc.
> still fits the parameter even of a volatile parameter pointcut.
>
> I try to attach the example code to this mail. If it turns out to be
> filtered out I'll cite it in another one.
> Best regards
>
> Arnd-Hendrik
>
>
> Zitat von Panu Bloigu <panu.bloigu at gmail.com>:
>
>> Hello.
>>
>> arnd-hendrik.mathias at nefkom.net wrote:
>>> Hi,
>>> I just recognized one strange effect with parameter types in
>>> pointcuts: If I declare one parameter of a function as volatile
>>> type (in the source code as well as in the aspect) ac++ does no
>>> longer match this execution (nor call) pointcut ( execution ( "%
>>> blah ( ... )" ) && args ( bli, blubb )).
>>> Has anyone experienced this before?
>>> Regards
>> If you think that you have found a bug in ac++, then could you please
>> post a compilable code example that demonstrates the problem. If at all
>> possible, it would be good to try to minimize the code example so that
>> it still is compilable and still demonstrates the problem. If your
>> findings indeed turn out to be a bug in ac++, then I'm pretty sure the
>> AspectC++ developers will appreciate that you reported it.
>>>
>>>
>>> Arnd-Hendrik
>>>
>>> P.S.: I know that a volatile parameter in a function looks somewhat
>>> uncommon, but I just stripped it down for debugging purposes. In
>>> real life it's a typedef'ed HW-Register value and this must be
>>> volatile.
>>
>> It's hard to say if this is relevant in your case, but I think that
>> using type aliases (i.e. typedef'd type names) in pointcut descriptions
>> is considered problematic. I once posted a question about this on the
>> list, and here's Olaf's explanation on the issues involved:
>> http://aspectc.org/pipermail/aspectc-user/2007-January/001098.html
>>
>> -- Panu
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> aspectc-user mailing list
> aspectc-user at aspectc.org
> http://www.aspectc.org/mailman/listinfo/aspectc-user
More information about the aspectc-user
mailing list