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

  • Home
  • SEARCH
  • 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 874787
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T11:09:38+00:00 2026-05-15T11:09:38+00:00

I started getting the error, error C2059: syntax error : ‘default argument’ for a

  • 0

I started getting the error, “error C2059: syntax error : ‘default argument'” for a line of code that declared a function with a string argument that was given a default parameter. This was obviously a bit frustrating, as the error message was not exactly enlightening (I know it’s a ‘default argument’!), and the exact declaration would work elsewhere.

After shifting about the declaration a bit, I found its position in its containing class actually had an effect. Narrowing it down, I found that I was declaring a different function somewhat erroneously, by including a semicolon after one of its default parameters. The compiler seemed perfectly fine with that, which seemed a bit odd. I investigated a bit more, and came up with the following test case to try to figure out the essence of what was going on:

enum TestEnum1
{
   TEST_ONE
};
class TestClass
{
public:
   enum TestEnum2
   {
      TEST_TWO,
      TEST_THREE,
      TEST_FOUR
   };
   void Func1( int iParm = TEST_ONE; ); // additional semicolon here
   void Func2( std::string strParm = "" );
};

As the code above stands, Func2 will produce the compilation error I mentioned above. If I move Func2 above Func1, then everything compiles fine.

If I switch the default parameter in Func1 to an explicit number or use an enum declared within TestClass, then I get an expected syntax error for that line.

So essentially, the strange thing seems to be that if I set a default parameter’s value to an enum not defined directly in the current class and am a little too semicolon-happy, the compiler will ignore the syntax error, until some other seemingly-unrelated thing finally causes the parser to die in a very inscrutable way.

Am I just missing something completely? Is this expected behavior? I’m hesitant to go calling it a bug in the compiler, certainly, but this hardly seems correct. If it’s just me misunderstanding something about the standard, then I’d like to know where I’m wrong.

  • 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-15T11:09:39+00:00Added an answer on May 15, 2026 at 11:09 am

    Agreed with @tlayton. Having dabbled a bit in parsers myself, I can attest that generating good error messages for syntax errors that confuse the parser’s sense of scope can be very hard to do.

    This particular case is however close to a defect. The irony is that in VS2010, the compiler still generates the same lousy error message but the IntelliSense parser actually catches it:

    3   IntelliSense: expected a ')'    c:\projects\cpptemp14\cpptemp14.cpp 20  36  cpptemp14
    

    That’s borked. You can report it at connect.microsoft.com. Let me know if you don’t want to take the time, I’ll report it (MVP duty).

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

Sidebar

Ask A Question

Stats

  • Questions 436k
  • Answers 436k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer I finally used this approach - it gives flexibility in… May 15, 2026 at 3:46 pm
  • Editorial Team
    Editorial Team added an answer preg_match('/^[a-z0-9\p{P}]*$/i', $subject); This will return 1 if $subject is composed… May 15, 2026 at 3:46 pm
  • Editorial Team
    Editorial Team added an answer Well you've written a plugin, so you have to use… May 15, 2026 at 3:46 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.