When operator->() returns a pointer to a built-in type (e.g., char), it
doesn't work properly on either VC++ 2003 or VC++ 2005. The following
valid C++ program is rejected by VC++, saying:
error C2839: invalid return type 'C *' for overloaded 'operator ->'

//////////////////////////////////////////////////////////////////////
typedef char C;

template <typename T>
class SmartPointer {
T * m_ptr;
public:
T * operator->() const {
return m_ptr;
}
SmartPointer(T* arg) : m_ptr(arg) {
}
};

int main() {
C* rawPtr = 0;
SmartPointer<C> smartPtr = 0;

rawPtr->~C(); // Okay :-)
smartPtr.operator->()->~C(); // Okay :-)
smartPtr->~C(); // error C2839!!! :-(
}
//////////////////////////////////////////////////////////////////////

Is this a known bug? I didn't find it at
https://connect.microsoft.com/VisualStudio/feedback

FYI, the thing is relevant to the resolution of C++ Standard Library
issue 659, "istreambuf_iterator should have an operator->()"
http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#659


Kind regards,
--
Niels Dekker
http://www.xs4all.nl/~nd/dekkerware
Scientific programmer at LKEB, Leiden University Medical Center

Re: Compiler bug: error C2839 when operator-> returns pointer to built-in type by David

David
Mon May 28 08:12:26 CDT 2007

>When operator->() returns a pointer to a built-in type (e.g., char), it
>doesn't work properly on either VC++ 2003 or VC++ 2005. The following
>valid C++ program is rejected by VC++, saying:
> error C2839: invalid return type 'C *' for overloaded 'operator ->'

It's the same with the Orcas B1 compiler too, and since the Comeau
online compiler doesn't object it probably is a bug.

>I didn't find it at
>https://connect.microsoft.com/VisualStudio/feedback

Submit it as a bug against Orcas B1, supply a trivial project so
someone can repro it and mention that Comeau (and presumably other)
compilers don't object to it and the other information you mentioned
here.

Post a link to your bug report here and I'll verify it for you.

Dave

Re: Compiler bug: error C2839 when operator-> returns pointer to built-in type by Niels

Niels
Mon May 28 09:31:17 CDT 2007

>> When operator->() returns a pointer to a built-in type (e.g., char),
>> it doesn't work properly on either VC++ 2003 or VC++ 2005. The
>> following valid C++ program is rejected by VC++, saying:
>> error C2839: invalid return type 'C *' for overloaded 'operator ->'

David Lowndes wrote:
> It's the same with the Orcas B1 compiler too, and since the Comeau
> online compiler doesn't object it probably is a bug.

> Submit it as a bug against Orcas B1, supply a trivial project so
> someone can repro it and mention that Comeau (and presumably other)
> compilers don't object to it and the other information you mentioned
> here.

Thank you, Dave. Unfortunately I have no idea how to submit a VC++ bug.
I went to https://connect.microsoft.com/VisualStudio/feedback and signed
in, using my Hotmail account (aka "Windows Live ID").

But there was no button saying "Submit a bug". :-(

It seems like I need to "participate in a connection", before I can
submit a VC++ bug, right? I'd rather just submit the bug without
needing to do all that registration stuff! But anyway, I still tried to
participate, but I failed so far:

First I went to My Participation:
https://connect.microsoft.com/myparticipation.aspx?wa=wsignin1.0
It told me I'm not yet participating in any programs.

Then I tried Available Connections:
https://connect.microsoft.com/availableconnections.aspx
Scrolled down to "Visual Studio and .NET Framework"

No way to "apply" to participate. Only a link that brought me to:
https://connect.microsoft.com/VisualStudio
Which contains a link, "Submit a Bug or Suggestion"
And this brings me to:
https://connect.microsoft.com/feedback/default.aspx?SiteID=210&wa=wsignin1.0

That's where I got lost!

Please feel free to submit the bug yourself, David. Especially because
you tested it on Orcas B1, while I haven't even got Orcas installed.
And because you know how to submit a bug :-)

Kind regards, Niels



Re: Compiler bug: error C2839 when operator-> returns pointer to built-in type by David

David
Mon May 28 11:30:33 CDT 2007

>Please feel free to submit the bug yourself, David. Especially because
>you tested it on Orcas B1, while I haven't even got Orcas installed.
>And because you know how to submit a bug :-)

No problem Niels.

https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=278779

If you can :) - add your vote/validation.

BTW, is this as a blocking issue for you, or do you have a workaround?

Dave

Re: Compiler bug: error C2839 when operator-> returns pointer to built-in type by Niels

Niels
Mon May 28 13:21:00 CDT 2007

David Lowndes wrote:
> https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=278779
> If you can :) - add your vote/validation.

Thanks, I just did :-)

> is this as a blocking issue for you, or do you have a workaround?

I just hope it doesn't "block" the Standard C++ Committee from resolving "my
Standard Library issue",
www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#659 :-)

Fixing the bug would definitely be an improvement to the compiler's support
of generic programming. I do have a workaround, but it's rather lame: just
don't use the syntax "p->m" within generic code. Instead, use "(*p).m".
I'd rather not fill in this workaround on the website, because I don't like
it! It isn't only rather clumsy. Doing "(*p).m" may also be slower than
"p->m", because it may involve returning an object by value.


Kind regards, Niels



Re: Compiler bug: error C2839 when operator-> returns pointer to built-in type by Niels

Niels
Mon Jun 04 11:38:57 CDT 2007

David Lowndes wrote:
> https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=278779

Unfortunately its status is set to "Closed (Won't Fix)".

Microsoft posted onto the feedback page (5/31/2007):
> Thank you for sending us feedback. The Visual C++ team has evaluated
> the bug and determined it does not meet the guidelines necessary to
> warrant a fix. To understand these guidelines please refer to
> http://blogs.msdn.com/vcblog/articles/621116.aspx.
...
> Comments from the triage team: While a valid bug, this does not meet
> the triage guidelines for Orcas.
>
> Thanks once again for taking the time to send us feedback,
> The Visual C++ Triage Team


Hope this issue does not delay the addition of "concepts" to VC++! For
instance because the std::InputIterator concept might require an iterator to
properly support the syntax i->m, even if the iterator points to a built-in
type. (The Standard C++ Committee is planning to add concepts to the
language in 2009. <www.generic-programming.org/languages/conceptcpp>)


Kind regards, Niels




Re: Compiler bug: error C2839 when operator-> returns pointer to built-in type by David

David
Mon Jun 04 12:04:49 CDT 2007

>> https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=278779
>
>Unfortunately its status is set to "Closed (Won't Fix)".

Yep :(

I'm giving up hope of any C++ compiler bugs getting fixed for Orcas -
I suspect they don't want to spend the time when the compiler is going
to be replaced for the Phoenix version in the next version (at least
that's what I assume is going to happen).

Dave

Re: Compiler bug: error C2839 when operator-> returns pointer to built-in type by Ben

Ben
Mon Jun 04 19:38:48 CDT 2007


"David Lowndes" <DavidL@example.invalid> wrote in message
news:i4h8635kpabg8nlmnlu40bnqblakv2v9g4@4ax.com...
>>> https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=278779
>>
>>Unfortunately its status is set to "Closed (Won't Fix)".
>
> Yep :(
>
> I'm giving up hope of any C++ compiler bugs getting fixed for Orcas -

Looking at this page:
http://download.microsoft.com/download/9/F/7/9F79D1D8-72FD-407C-88F7-D2254EB4E0AD/VSNETSDKcontents.htm

I can understand why they aren't accepting new bug reports, how 'bout you?

I was about to install Orcas and try it out, before I saw that list.



Re: Compiler bug: error C2839 when operator-> returns pointer to built-in type by Tom

Tom
Mon Jun 04 23:28:12 CDT 2007

I think it's fair to expect at this point to still have a few issues.
Typically, the "won't fix" message shows up when they can't reproduce the
problem or they don't think the problem is serious enough to potentially
break something else with a fix. We do the same thing with our software,
but we typically mark it as "Fix/Later" in those cases.

It looks like, in this case, the team evaluating the problem decided that
this wasn't a big enough deal to warrant a fix. That could be because the
fix might caues more problems than the original problem. It's tough to tell
from the comments.

It's also tough to tell if they intend to fix it in the future. Perhaps
it's too late in the game to add new text messages to the compiler that may
need to be translated.

Tom

"Ben Voigt [C++ MVP]" <rbv@nospam.nospam> wrote in message
news:uWiQKowpHHA.4388@TK2MSFTNGP03.phx.gbl...
>
> "David Lowndes" <DavidL@example.invalid> wrote in message
> news:i4h8635kpabg8nlmnlu40bnqblakv2v9g4@4ax.com...
>>>> https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=278779
>>>
>>>Unfortunately its status is set to "Closed (Won't Fix)".
>>
>> Yep :(
>>
>> I'm giving up hope of any C++ compiler bugs getting fixed for Orcas -
>
> Looking at this page:
> http://download.microsoft.com/download/9/F/7/9F79D1D8-72FD-407C-88F7-D2254EB4E0AD/VSNETSDKcontents.htm
>
> I can understand why they aren't accepting new bug reports, how 'bout you?
>
> I was about to install Orcas and try it out, before I saw that list.
>


Re: Compiler bug: error C2839 when operator-> returns pointer to built-in type by David

David
Tue Jun 05 06:01:46 CDT 2007

>> I'm giving up hope of any C++ compiler bugs getting fixed for Orcas -
>
>Looking at this page:
>http://download.microsoft.com/download/9/F/7/9F79D1D8-72FD-407C-88F7-D2254EB4E0AD/VSNETSDKcontents.htm
>
>I can understand why they aren't accepting new bug reports, how 'bout you?

I don't think it's a case that they're not "accepting" bug reports,
just that they won't fix any unless they're real show stoppers. I
*hope* they are keeping the bug reports and ensuring the next
generation compiler will resolve them.

Dave

Re: Compiler bug: error C2839 when operator-> returns pointer to built-in type by Ben

Ben
Tue Jun 05 09:09:41 CDT 2007


"David Lowndes" <DavidL@example.invalid> wrote in message
news:2gga631kpdpehnkaj08eeu360na660pt70@4ax.com...
>>> I'm giving up hope of any C++ compiler bugs getting fixed for Orcas -
>>
>>Looking at this page:
>>http://download.microsoft.com/download/9/F/7/9F79D1D8-72FD-407C-88F7-D2254EB4E0AD/VSNETSDKcontents.htm
>>
>>I can understand why they aren't accepting new bug reports, how 'bout you?
>
> I don't think it's a case that they're not "accepting" bug reports,
> just that they won't fix any unless they're real show stoppers. I
> *hope* they are keeping the bug reports and ensuring the next
> generation compiler will resolve them.

Ok, yes. I think they're not deleting the reports, but retagging them with
the next milestone (VC++ 2011 CTP or whatever).

>
> Dave



Re: Compiler bug: error C2839 when operator-> returns pointer to built-in type by Carl

Carl
Tue Jun 05 09:17:57 CDT 2007

David Lowndes wrote:
>>> I'm giving up hope of any C++ compiler bugs getting fixed for Orcas
>>> -
>>
>> Looking at this page:
>> http://download.microsoft.com/download/9/F/7/9F79D1D8-72FD-407C-88F7-D2254EB4E0AD/VSNETSDKcontents.htm
>>
>> I can understand why they aren't accepting new bug reports, how
>> 'bout you?
>
> I don't think it's a case that they're not "accepting" bug reports,
> just that they won't fix any unless they're real show stoppers. I
> *hope* they are keeping the bug reports and ensuring the next
> generation compiler will resolve them.

They're keeping them. Post Orcas (just like post-Whidbey and post-Everett
before it), a pass will be made through the bugs and some (not all) will be
re-opened for work. How many and what the criteria for re-opening are will
depend on the goals of the overall release.

-cd