Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6730097
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T10:22:03+00:00 2026-05-26T10:22:03+00:00

I had the following code in a sample application: ostream& operator<< (ostream& os, const

  • 0

I had the following code in a sample application:

ostream& operator<< (ostream& os, const ReferenceTest& rt)
{
    os << rt.counter;  //In this scenario, rt has a public int called counter
}

I was surprised to learn that this code compiled without issue using GCC 4.6.1. It fails when using Visual Studio 2010 for the reason I would have expected, namely that I’m not returning a reference to an ostream. However, the output for the program when compiled for the two platforms is identical (I have a trivial main() that writes test output).

Which is standards compliant? Am I missing something obvious here?

-Derek

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T10:22:03+00:00Added an answer on May 26, 2026 at 10:22 am

    Did you compile with warnings enabled? I get warning: control reaches end of non-void function with g++.

    You certainly don’t want a compiler to stop at the first error in your code. You want it to catch as many as it can in one swell foop. To do this, the compiler has to patch your buggy code so it can press on. In this case, the patch is obvious: Return the stream provided as an argument.

    Never trust those “fixes” supplied for free by the compiler. They are anything but free. Fix your code instead.

    And always compile with warnings enabled.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've been following the tutorial on building a sample GWT Application: http://code.google.com/webtoolkit/doc/latest/tutorial/gettingstarted.html I then
Say I had the following code: % Cellmode_subfunction_test.m %% Cell 1 foo(1); %% Cell
Recently I attended a lecture concerning some design patterns: The following code had been
I had no problem at all running the following code on a local server,
I had the following line snippet of code that searches for a propery of
If I had to following file on my development branch: # file.rb class Code
I had the following HTML page rendering to use the Google Maps API. This
The following code samples produce the same error when I perform the SAVEAS: Microsoft.Office.Interop.Excel.Application
Initially this demo application I'm working on had just one page with a simple
Yesterday, I had programmed a simple Bluetooth network for my iPhone application. This morning,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.