Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home for chromium.org
« Groups Home
Message from discussion FYI: Move-only class + windows C++ compiler + ternary operator

Received: by 10.236.185.103 with SMTP id t67mr477912yhm.49.1343986992912;
        Fri, 03 Aug 2012 02:43:12 -0700 (PDT)
X-BeenThere: chromium-...@chromium.org
Received: by 10.101.58.14 with SMTP id l14ls1224615ank.0.gmail; Fri, 03 Aug
 2012 02:43:04 -0700 (PDT)
Received: by 10.236.184.9 with SMTP id r9mr972919yhm.18.1343986984550;
        Fri, 03 Aug 2012 02:43:04 -0700 (PDT)
Received: by 10.236.184.9 with SMTP id r9mr972917yhm.18.1343986984527;
        Fri, 03 Aug 2012 02:43:04 -0700 (PDT)
Return-Path: <eisin...@google.com>
Received: from mail-gh0-f180.google.com (mail-gh0-f180.google.com [209.85.160.180])
        by mx.google.com with ESMTPS id p20si4237110anl.16.2012.08.03.02.43.04
        (version=TLSv1/SSLv3 cipher=OTHER);
        Fri, 03 Aug 2012 02:43:04 -0700 (PDT)
Received-SPF: pass (google.com: domain of eisin...@google.com designates 209.85.160.180 as permitted sender) client-ip=209.85.160.180;
Authentication-Results: mx.google.com; spf=pass (google.com: domain of eisin...@google.com designates 209.85.160.180 as permitted sender) smtp.mail=eisin...@google.com; dkim=pass header...@google.com
Received: by ghbz12 with SMTP id z12so543395ghb.25
        for <chromium-...@chromium.org>; Fri, 03 Aug 2012 02:43:04 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=google.com; s=20120113;
        h=mime-version:sender:in-reply-to:references:from:date
         :x-google-sender-auth:message-id:subject:to:cc:content-type
         :x-system-of-record;
        bh=+XjME6NDAkjKi4y+JwytHJTT2fSAIA3y0q5hYWfl0Is=;
        b=NW46tBqEVEM1P1AUzvbH+SDQ8JyrQFnoDRACAI50MBUZqTyEJwPIkjHCVI1SI/cmOP
         C5L4D1PrJgPkt4efGQzU+8GqoAGgUo0rvJl9x8MPpH3jeUGDl+RfIUqxzoseXMDGtfHZ
         ozDpKAIinEbNCiost9196nDq7APzdAvDsArPaJvBa6PmEYb+0TM+lrbwex44pdNVu+3m
         n8h75QdU6lx/hvxR0oxvMk0MJb1ixf1MFn9kt7T4h4IuseJ3/VBMvyq1Hkb5Xt9qSzBU
         N0zR7TG72rd9ruCI+qP/ChQvMQaDbDX5yyCHLxUYjFomRDd1r/dT1/y/pxDxrrVbKP47
         ZTzQ==
        d=google.com; s=20120113;
        h=mime-version:sender:in-reply-to:references:from:date
         :x-google-sender-auth:message-id:subject:to:cc:content-type
         :x-system-of-record:x-gm-message-state;
        bh=+XjME6NDAkjKi4y+JwytHJTT2fSAIA3y0q5hYWfl0Is=;
        b=Fk2b6EE7I+UwKOehxkM8zgGn6LRzmhRyley8LiVC1i76lVUhoj/dW1D8gF027OaPKr
         Q+C4k5M/oN4PBMl36+BkXcSy/7NRLPhv8a/sZWoZciTVDXaZIA0I7dXoJvbE7NJU9/7L
         xrrY/wmD2RR2GugYPZdBu9LwISmVDmvcKnGRQQdfUTV4qJhKrfu6nrI542Y17kaNNqxS
         IT0kiXcNF4HP14e2fRPqbJQ/d2XJSBI9xz48z9Smv9/CvDgAXLTLl3CwFOfRTLEjC4c7
         TLXtVCwBrjRv2JXObrYoVG1DHfhf1V6X6253KCQ3FtO7ZhJ6AK5Jcze0m/LncoWSutAx
         r49w==
Received: by 10.50.216.202 with SMTP id os10mr9400626igc.17.1343986984170;
        Fri, 03 Aug 2012 02:43:04 -0700 (PDT)
Received: by 10.50.216.202 with SMTP id os10mr9400600igc.17.1343986983948;
 Fri, 03 Aug 2012 02:43:03 -0700 (PDT)
MIME-Version: 1.0
Sender: eisin...@google.com
Received: by 10.231.12.134 with HTTP; Fri, 3 Aug 2012 02:42:43 -0700 (PDT)
In-Reply-To: <CAKUbbxJrqgZFN66-mup4C1s07sTXT72uwQQJPaLZON1P70Z...@mail.gmail.com>
References: <babfc769-6b96-47cb-b029-04b957877...@chromium.org> <CAKUbbxJrqgZFN66-mup4C1s07sTXT72uwQQJPaLZON1P70Z...@mail.gmail.com>
From: Jochen Eisinger <joc...@chromium.org>
Date: Fri, 3 Aug 2012 11:42:43 +0200
Message-ID: <CALjhuic4OmO7_2bLZVj-VWYUGm8WA7QRD5ud-NgidXGObMe...@mail.gmail.com>
Subject: Re: [chromium-dev] FYI: Move-only class + windows C++ compiler +
 ternary operator
To: mniss...@google.com
Cc: v...@chromium.org, chromium-...@chromium.org
Content-Type: multipart/alternative; boundary=14dae9341251c2d2a604c6595a5b
X-System-Of-Record: true
X-Gm-Message-State: ALoCoQmytehlXhDW7SXsNmeu2bdCO+V1koH4r/VL6qoQxra2xAIzQBnm/QA7YHcDbmJo0U249CQQtnzokRjgMDstTrvD2qJ/xAYPxdglh4v8r6oJVj10z6DDJ6wnmtKvCFnchxZP4E3BUZmqhVtN+bpb9N5WEP/UPiLrtXYB1ISsCCnAPcNP0mWy/j/GBekTDwYgDmTxMiX/6VQtaU1YEi9oa7HWq740nw==

--14dae9341251c2d2a604c6595a5b
Content-Type: text/plain; charset=ISO-8859-1

The return value of a ternary operator is the type of the second
expressions, which is the (private) class
scoped_ptr<const::DictionaryValue>::RValue. The third expression is of type
scoped_ptr<const::DictionaryValue> which you cannot cast to ...::RValue

I guess that's what the error message is trying to tell you

-jochen

On Fri, Aug 3, 2012 at 10:46 AM, Mattias Nissler <mniss...@chromium.org>wrote:

>
> On Fri, Aug 3, 2012 at 10:13 AM, vabr <v...@chromium.org> wrote:
>
>> Hi all,
>>
>> The following describes a strange issue of the compiler on win_rel try
>> bot.
>> Albert Wong was very kind and took a look at this, and said he was not
>> sure whether this is a compiler bug or something which can be fixed in our
>> code (base/move.h or scoped_ptr). Therefore I have not filed a bug and
>> I'm only posting a work-around here just in case anybody hits the same
>> problem later. If you think this is something we can and should fix, feel
>> free to let me know and I'll file the bug.
>>
>> The following code seems OK to me and (with details in) compiles all
>> right on linux and mac try-bots:
>>
>> scoped_ptr<const DictionaryValue> GetDictionaryFromJson(/*...*/) {
>>   bool success;
>>   // ...
>>   scoped_ptr<const DictionaryValue> dictionary(/*...*/);
>>   return success ? dictionary.Pass() : scoped_ptr<const
>> DictionaryValue>();
>> }
>>
>> However, the win_rel bot complained<http://build.chromium.org/p/tryserver.chromium/builders/win_rel/builds/49078/steps/compile/logs/stdio> (search
>> for "C2248" on that page) about the return statement, pointing to the line
>> where scoped_ptr employs MOVE_ONLY_TYPE_FOR_**CPP_03, and saying that
>> "'scoped_ptr<C>::scoped_ptr' : cannot access private member declared in
>> class 'scoped_ptr<C>'". Interestingly after I expanded<http://codereview.chromium.org/10694055/diff2/77002:75041/chrome/browser/extensions/api/web_request/web_request_api_unittest.cc>
>>  the ternary operator to a full if-else statement, the compiler accepted
>> it.
>>
>
> For posterity, here is the full error message (the log will become
> unavailable at some point):
>
> E:\b\build\slave\win\build\src\chrome\browser\extensions\api\web_request\web_request_api_unittest.cc(96)
> :error C2248: 'scoped_ptr<C>::scoped_ptr' : cannot access private member
> declared in class 'scoped_ptr<C>'
>
>         with
>         [
>             C=const base::DictionaryValue
>         ]
>         ..\base/memory/scoped_ptr.h(134) : see declaration of
> 'scoped_ptr<C>::scoped_ptr'
>         with
>         [
>             C=const base::DictionaryValue
>
>         ]
>>
>>
>> Vaclav
>>
>> --
>> Chromium Developers mailing list: chromium-...@chromium.org
>> View archives, change email options, or unsubscribe:
>> http://groups.google.com/a/chromium.org/group/chromium-dev
>>
>
>  --
> Chromium Developers mailing list: chromium-...@chromium.org
> View archives, change email options, or unsubscribe:
> http://groups.google.com/a/chromium.org/group/chromium-dev
>

--14dae9341251c2d2a604c6595a5b
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

The return value of a ternary operator is the type of the second expression=
s, which is the (private) class scoped_ptr&lt;const::DictionaryValue&gt;::R=
Value. The third expression is of type scoped_ptr&lt;const::DictionaryValue=
&gt; which you cannot cast to ...::RValue<div>

<br></div><div>I guess that&#39;s what the error message is trying to tell =
you</div><div><br></div><div>-jochen<br><br><div class=3D"gmail_quote">On F=
ri, Aug 3, 2012 at 10:46 AM, Mattias Nissler <span dir=3D"ltr">&lt;<a href=
=3D"mailto:mniss...@chromium.org" target=3D"_blank">mniss...@chromium.org</=
a>&gt;</span> wrote:<br>

<blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p=
x #ccc solid;padding-left:1ex"><br><div class=3D"gmail_quote"><div class=3D=
"CSS_CV_QUOTED_TEXT_">On Fri, Aug 3, 2012 at 10:13 AM, vabr <span dir=3D"lt=
r">&lt;<a href=3D"mailto:v...@chromium.org" target=3D"_blank">vabr@chromium=
.org</a>&gt;</span> wrote:<br>

<blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p=
x #ccc solid;padding-left:1ex">

Hi all,<div><br></div><div>The following describes=A0<span style=3D"font-fa=
mily:arial,sans-serif;font-size:12.727272033691406px">a strange issue of th=
e compiler on win_rel try bot.</span></div><div><span style=3D"font-family:=
arial,sans-serif;font-size:12.727272033691406px">Albert Wong was very kind =
and took a look at this, and said he was not sure whether this is a compile=
r bug or something which can be fixed in our code (</span><span style=3D"fo=
nt-family:arial,sans-serif;font-size:12.727272033691406px">base/move.h or s=
coped_ptr). Therefore I have not filed a bug and I&#39;m only posting a=A0<=
/span><span style=3D"font-family:arial,sans-serif;font-size:12.727272033691=
406px">work-around</span><span style=3D"font-family:arial,sans-serif;font-s=
ize:12.727272033691406px">=A0here just in case anybody hits the same proble=
m later. If you think this is something we can and should fix, feel free to=
 let me know and I&#39;ll file the bug.</span></div>



<div><span style=3D"font-family:arial,sans-serif;font-size:12.7272720336914=
06px"><br></span></div><div><span style=3D"font-family:arial,sans-serif;fon=
t-size:12.727272033691406px">The following code seems OK to me and (with de=
tails in) compiles all right on linux and mac try-bots:</span></div>



<div><div style=3D"font-family:arial,sans-serif;font-size:12.72727203369140=
6px"><br></div><div style=3D"font-family:arial,sans-serif;font-size:12.7272=
72033691406px"><font face=3D"courier new, monospace">scoped_ptr&lt;const Di=
ctionaryValue&gt; GetDictionaryFromJson(/*...*/) {</font></div>



<div style=3D"font-family:arial,sans-serif;font-size:12.727272033691406px">=
<font face=3D"courier new, monospace">=A0 bool success;</font></div><div st=
yle=3D"font-family:arial,sans-serif;font-size:12.727272033691406px"><font f=
ace=3D"courier new, monospace">=A0 // ...</font></div>



<div style=3D"font-family:arial,sans-serif;font-size:12.727272033691406px">=
<font face=3D"courier new, monospace">=A0=A0scoped_ptr&lt;const DictionaryV=
alue&gt; dictionary(/*...*/);</font></div><div style=3D"font-family:arial,s=
ans-serif;font-size:12.727272033691406px">



<font face=3D"courier new, monospace">=A0=A0return success ? dictionary.Pas=
s() : scoped_ptr&lt;const DictionaryValue&gt;();</font></div><div style=3D"=
font-family:arial,sans-serif;font-size:12.727272033691406px"><font face=3D"=
courier new, monospace">}</font></div>



<div style=3D"font-family:arial,sans-serif;font-size:12.727272033691406px">=
<br></div><div style=3D"font-family:arial,sans-serif;font-size:12.727272033=
691406px">However, the win_rel bot=A0<a href=3D"http://build.chromium.org/p=
/tryserver.chromium/builders/win_rel/builds/49078/steps/compile/logs/stdio"=
 style=3D"color:rgb(17,85,204)" target=3D"_blank">complained</a>=A0(search =
for &quot;C2248&quot; on that page) about the return statement, pointing to=
 the line where scoped_ptr employs=A0MOVE_ONLY_TYPE_FOR_<u></u>CPP_03, and =
saying that &quot;&#39;scoped_ptr&lt;C&gt;::scoped_ptr&#39; : cannot access=
 private member declared in class &#39;scoped_ptr&lt;C&gt;&#39;&quot;.=A0<s=
pan style=3D"font-size:12.727272033691406px">Interestingly after I</span><s=
pan style=3D"font-size:12.727272033691406px">=A0</span><a href=3D"http://co=
dereview.chromium.org/10694055/diff2/77002:75041/chrome/browser/extensions/=
api/web_request/web_request_api_unittest.cc" style=3D"font-size:12.72727203=
3691406px;color:rgb(17,85,204)" target=3D"_blank">expanded</a><span style=
=3D"font-size:12.727272033691406px">=A0</span><span style=3D"font-size:12.7=
27272033691406px">the ternary operator to a full if-else statement, the com=
piler accepted it.</span></div>



</div></blockquote><div><br></div></div><div>For=A0posterity, here is the f=
ull error message (the log will become unavailable at some point):</div><di=
v><span style=3D"font-family:&#39;Courier New&#39;,courier,monotype;font-si=
ze:16px"><br>



</span></div>E:\b\build\slave\win\build\src\chrome\browser\extensions\api\w=
eb_request\web_request_api_unittest.cc(96) :error C2248: &#39;scoped_ptr&lt=
;C&gt;::scoped_ptr&#39; : cannot access private member declared in class &#=
39;scoped_ptr&lt;C&gt;&#39;<br>



<br>=A0 =A0 =A0 =A0 with<br>=A0 =A0 =A0 =A0 [<br>=A0 =A0 =A0 =A0 =A0 =A0 C=
=3Dconst base::DictionaryValue<br>=A0 =A0 =A0 =A0 ]<br>=A0 =A0 =A0 =A0 ..\b=
ase/memory/scoped_ptr.h(134) : see declaration of &#39;scoped_ptr&lt;C&gt;:=
:scoped_ptr&#39;<br>=A0 =A0 =A0 =A0 with<br>=A0 =A0 =A0 =A0 [<br>



=A0 =A0 =A0 =A0 =A0 =A0 C=3Dconst base::DictionaryValue<div class=3D"CSS_CV=
_QUOTED_TEXT_"><br>=A0 =A0 =A0 =A0 ]<blockquote class=3D"gmail_quote" style=
=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div sty=
le=3D"font-family:arial,sans-serif;font-size:12.727272033691406px">



<span style=3D"font-size:12.727272033691406px"><br></span></div><div style=
=3D"font-family:arial,sans-serif;font-size:12.727272033691406px"><span styl=
e=3D"font-size:12.727272033691406px">Vaclav</span></div><span><font color=
=3D"#888888">

<p></p>

-- <br>
Chromium Developers mailing list: <a href=3D"mailto:chromium-...@chromium.o=
rg" target=3D"_blank">chromium-...@chromium.org</a><br>
View archives, change email options, or unsubscribe: <br>
    <a href=3D"http://groups.google.com/a/chromium.org/group/chromium-dev" =
target=3D"_blank">http://groups.google.com/a/chromium.org/group/chromium-de=
v</a><br>
</font></span></blockquote></div></div><div class=3D"CSS_CV_TRIMMABLE_"><di=
v class=3D"CSS_CV_ELIDED_TEXT_"><br>

<p></p>

-- <br>
Chromium Developers mailing list: <a href=3D"mailto:chromium-...@chromium.o=
rg" target=3D"_blank">chromium-...@chromium.org</a><br>
View archives, change email options, or unsubscribe: <br>
    <a href=3D"http://groups.google.com/a/chromium.org/group/chromium-dev" =
target=3D"_blank">http://groups.google.com/a/chromium.org/group/chromium-de=
v</a><br>
</div></div></blockquote></div><br></div>

--14dae9341251c2d2a604c6595a5b--