Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 354433

Summary: Parser flags a function as in error when return comes after a goto label
Product: [Tools] CDT Reporter: Nathan Baker <nathanb>
Component: cdt-codanAssignee: CDT Codan Inbox <cdt-codan-inbox>
Status: CLOSED DUPLICATE QA Contact: Elena Laskavaia <elaskavaia.cdt>
Severity: normal    
Priority: P3 CC: cdtdoug, malaperle, nathanb, xhpohanka, yevshif, zeratul976
Version: 8.0   
Target Milestone: ---   
Hardware: All   
OS: All   
Whiteboard:

Description Nathan Baker CLA 2011-08-10 16:06:59 EDT
Build Identifier: 20110615-0604

If a function in a project has a return type, the parser will flag it as not returning a value if the return statement follows a goto label.

The error message reads "No return, in function returning non-void"

Reproducible: Always

Steps to Reproduce:
static int
foo(int argc, char** argv)
{

	if (argc > 0) {
		goto done;
	}

done:
	return 0;
}
Comment 1 Tomasz Wesolowski CLA 2011-08-11 04:46:25 EDT
I can't reproduce that error. I think this has been fixed already (see bug 346559).
Comment 2 Nathan Baker CLA 2011-08-11 09:50:02 EDT
Any chance the change could get pulled into a 7.0.x build? Not all of us are using unreleased versions of CDT.
Comment 3 Tomasz Wesolowski CLA 2011-08-11 09:54:17 EDT
8.0 has been released since June, hasn't it?
Comment 4 Nathan Baker CLA 2011-09-06 17:48:05 EDT
Does not appear to be fixed in build 8.0.0.201106081058

I still see the same problem.
Comment 5 Jan Pohanka CLA 2011-10-07 02:10:56 EDT
I can confirm this behavior. It occurs only when the return statement is immediately after the label.

/*
 * aaa.c
 *
 *  Created on: 7.10.2011
 *      Author: honza
 */


int x(void)
{
	int aa = 0;
	if (aa > 0)
		goto label;
	return 0;
label:
	return -1;
}
Comment 6 Nathan Ridge CLA 2013-07-21 23:19:40 EDT
Do you still experience this error with CDT 8.2? I can't reproduce it.
Comment 7 Jan Pohanka CLA 2013-07-22 02:24:11 EDT
I can confirm that I cannot reproduce described behavior in actual builds. Seems to be fixed.
Comment 8 Nathan Baker CLA 2013-07-22 09:51:10 EDT
I confirm as well...the same code which reproduced the error earlier no longer reproduces it.
Comment 9 Marc-André Laperle CLA 2013-12-20 20:41:11 EST

*** This bug has been marked as a duplicate of bug 346559 ***