This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [v3] c++0x common_type patch


On Mon, Jul 7, 2008 at 9:51 PM, Douglas Gregor <dgregor@osl.iu.edu> wrote:
>
> On Thu, 2008-07-03 at 17:15 -0400, Chris Fairles wrote:
>> Patch for common_type. It's using __typeof__ instead of decltype until
>> PR 36628 is resolved. I'm not sure if the test cases are sufficient or
>> if the crazy macro's are allowed to be used in test cases (I didn't
>> see any being used in the other modification type traits).
>
> I'm looking at PR 36628, but the issue is a little deeper that I'd hoped
> for, and I don't have a patch ready yet. However, you can work around
> this bug by replacing this:
>
>  typedef __typeof__(true ? __t() : __u()) type;
>
> with something like:
>
>  bool __true_or_false();
>
>  // later on ...
>
>  typedef decltype(__true_or_false() ? __t() : __u()) type;
>
> Basically, the compiler is optimizing away the conditional before taking
> its decltype (because it knows we'll be taking the left-hand side). So,
> putting in the __true_or_false() suppresses that optimization and gets
> the right answer.
>
> Please make a note in common_type about PR 36628, so that we know to
> remove the hack when it gets fixed in the front end.
>
>  - Doug
>
>

Attached is updated patch.

Cheers,
Chris

Attachment: common_type2.patch.txt
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]