Does auto return type deduction force multiple functions to have the same return type?

Based on the following, GCC has the right behaviour in this case, but only by coincidence (see below):

ยง7.1.6.4 [dcl.spec.auto]/8

If the init-declarator-list contains more than one init-declarator, they shall all form declarations of variables.

Why only by coincidence? The error message is a clue. Changing the functions to deduce the same return type causes GCC to compile the code. While it’s correct in giving an error here, albeit a misleading one, it only does so when the deduced type is inconsistent. It should always give an error.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)