gcc/clang "expected primary-expression before" in CI
The compiler reached a point where an expression was required but found something that cannot start one - often a type name used where a value was expected, or a missing operand.
What this error means
A parse error reports "expected primary-expression before" a token such as a type name, > or ), frequently after a template syntax or missing-argument mistake.
gcc
app.cpp:6:18: error: expected primary-expression before '>' token
6 | auto v = make<int>();
| ^Common causes
How to fix it
Supply a valid expression
- Replace the type with a value, or fix the missing operand.
- For dependent template calls, add the template disambiguator.
gcc
obj.template make<int>(); // template keyword for dependent nameHow to prevent it
- Use values (not bare type names) where expressions are required and add the template keyword for dependent member templates.
Related guides
gcc/clang "call to non-constexpr function" in constant expression in CIFix gcc/clang errors where a constant expression calls a non-constexpr function in CI - a constexpr context r…
gcc/clang "template argument deduction/substitution failed" in CIFix gcc/clang "template argument deduction/substitution failed" in CI - a template candidate was rejected bec…