Issue 17386 - Internal error: backend\cgcod.c 1841
Summary: Internal error: backend\cgcod.c 1841
Status: RESOLVED WORKSFORME
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: x86_64 All
: P1 critical
Assignee: No Owner
URL:
Keywords: ice
Depends on:
Blocks:
 
Reported: 2017-05-09 14:37 UTC by Seiji Fujita
Modified: 2020-03-21 03:56 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Seiji Fujita 2017-05-09 14:37:06 UTC
/*
Title: Internal error: backend\cgcod.c 1841
dmd version: dmd.2.074.0
dmd option: dmd -c -m64 -O -release 

Internal error conditions
-------------------------
1. dmd.2.073.0 - dmd.2.074.0 only
2. dmd option is "m64 - O - release"
3. asm.dlang.org confirmed that internal error occurred in "dmd nightly build, - m64 - O - release"
4. The following code is minimized by Dustmite
*/
int[] bezier() {
	
	int[] polygon ;
	for (int i ; ; i++) {
		double t = i ;
		polygon[2 * i]     = cast(int)(t * t );
	}
}

/*
Original code:
location: dwt org.eclipse.swt.win32.win32.x86\src\org\eclipse\swt\custom\CBanner.d(161): 	int[] bezier(int x0, int y0, int x1, int y1, int x2, int y2, int x3, int y3, int count) {


int[] bezier(int x0, int y0, int x1, int y1, int x2, int y2, int x3, int y3, int count) {
		// The parametric equations for a Bezier curve for x[t] and y[t] where  0 <= t <=1 are:
		// x[t] = x0 + 3 (x1 - x0) t + 3 (x0 + x2 - 2x1) t ^ 2 + (x3 - x0 + 3x1 - 3x2) t ^ 3
		// y[t] = y0 + 3 (y1 - y0) t + 3 (y0 + y2 - 2y1) t ^ 2 + (y3 - y0 + 3y1 - 3y2) t ^ 3
		
	double a0 = x0;
	double a1 = 3 * (x1 - x0);
	double a2 = 3 * (x0 + x2 - 2 * x1);
	double a3 = x3 - x0 + 3 * x1 - 3 * x2;
	double b0 = y0;
	double b1 = 3 * (y1 - y0);
	double b2 = 3 * (y0 + y2 - 2 * y1);
	double b3 = y3 - y0 + 3 * y1 - 3 * y2;
	
	int[] polygon = new int[2 * count + 2];
	for (int i = 0; i <= count; i++) {
		double t = cast(double) i / cast(double) count;
		polygon[2 * i]     = cast(int)(a0 + a1 * t + a2 * t * t + a3 * t * t * t);
		polygon[2 * i + 1] = cast(int)(b0 + b1 * t + b2 * t * t + b3 * t * t * t);
	}
	return polygon;
}

/// Dustmite 
// dmd -c -m64 -O -release  CBanner_dmdInternalerror.d > out.txt
// dustmite src "dmd -c -m64 -O -release CBanner_dmdInternalerror.d | diff - ..\out.txt"

*/
Comment 1 basile-z 2019-05-30 20:06:54 UTC
fixed since 2.076.1 : https://run.dlang.io/is/Hsph09

now i'm quite surprised to see that because of the infinite loop no ReturnStatement is required.