Skip to content

Fail to parse expression inside parenthesis for post increment/decrement #118

Closed
@mingodad

Description

@mingodad

Here is a sample test to show the problem:

int fib(int n)
{
    if(n < 2) return 1;
    return fib(n-2)+fib(n-1);
}

int addOneFirst(int &n)
{
	return ++(n);
}

int addOneAfter(int &n)
{
	return (n)++;
}

int minusOneFirst(int &n)
{
	return --(n);
}

int minusOneAfter(int &n)
{
	return (n)--;
}

Output:

test.cpp:14:14: expected an expression
	return (n)++;
	            ^
test.cpp:24:14: expected an expression
	return (n)--;
	            ^

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions