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 8905109
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T02:18:33+00:00 2026-06-15T02:18:33+00:00

I was coding and accidentally left out a space between a constant reference and

  • 0

I was coding and accidentally left out a space between a constant reference and its default value. I was surprised to see that it came up as an error in Intellisense, so I compiled it, and sure enough, it doesn’t work in GCC 4.3.4, 4.5.1, or 4.7.2, and doesn’t work in Visual Studio 2012, either.

Here’s an equivalent sample that demonstrates the error:

struct S {
    S(const int &= 5){}    
};

int main(){}

This yields the following error in GCC, and similar ones in MSVC:

error: expected ‘,’ or ‘…’ before ‘&=’ token

I presume this is because &= is being treated as an operator, but I don’t know exactly what to search for in the standard to find more information about this case. &= just comes up with operator-specfic information.

Being curious, I decided to swap it out for an rvalue reference:

S(int &&= 5){}

Strangely enough, this compiles fine on both GCC 4.7.2 and MSVC, which means that &= isn’t always lexically paired as an operator.

Why does it work with an rvalue reference, but not an lvalue reference, and what does the standard have to say on the matter?

  • 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-06-15T02:18:34+00:00Added an answer on June 15, 2026 at 2:18 am

    This is generally known as the “principle of longest match”, or the “maximal munch”. Because && is a valid token and &&= is not (there’s no compound-assignment notation for &&), the longest token that &&= starts with is &&; after that’s been removed, there’s no opportunity for &= to be seen as a single token.

    This principle is common to many languages, though there are often exceptions to it. For example, in C++11, >> will be analyzed as > followed by > in a context like std::vector<std::vector<int>>.

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

Sidebar

Related Questions

Coding i came around to check for the vararg performance of Java. I write
Coding footer naively, if there's not enough content, then there will be empty space
The Zend Framework coding standard mentions the following: For files that contain only PHP
Coding a new 3D engine is fascinating but I there are so many out
When coding in Eclipse(Indigo), I accidentally hit a combination of keys which made this
So, we were coding an Android application in Eclipse, and we couldn't figure out
I was in middle of coding and accidentally put the following line of code
Coding HTML5 page for use in iPad Mobile Safari that has tag for embedding
Coding Platform ASP.NET 4.0 WebForms I have two pages that are relevant here Login.aspx
Some coding guidelines state that you should put the variable you are testing at

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.