3168 – Declaring structs as incomplete types no longer works

D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 3168 - Declaring structs as incomplete types no longer works
Summary: Declaring structs as incomplete types no longer works
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D1 (retired)
Hardware: All All
: P2 regression
Assignee: No Owner
URL:
Keywords: patch, rejects-valid
Depends on:
Blocks:
Reported: 2009年07月12日 08:48 UTC by nfxjfg
Modified: 2014年04月18日 09:12 UTC (History)
3 users (show)

See Also:


Attachments
Add an attachment (proposed patch, testcase, etc.)

Note You need to log in before you can comment on or make changes to this issue.
Description nfxjfg 2009年07月12日 08:48:16 UTC
In dmd 1.045, you used to be able to declare structs like this:
>>
struct FT_RasterRec;
<<
This no longer works with dmd 1.046.
The error message is:
test.d(1): Error: struct jk.FT_RasterRec has forward references
Declaring structs like this is often done in C to define incomplete types, and is especially useful when porting C headers. Also, the new behavior in dmd 1.046 breaks old code.
Comment 1 Don 2009年08月06日 13:08:07 UTC
Patch: Change one line in struct.c line 64. (This makes it the same as the code in D2).
---
void AggregateDeclaration::semantic2(Scope *sc)
{
 //printf("AggregateDeclaration::semantic2(%s)\n", toChars());
- if (scope)
+ if (scope && members)
 {	error("has forward references");
	return;
 }
Comment 2 Stewart Gordon 2009年08月15日 06:31:57 UTC
What bug reports are there already for the fact that we have a "has forward references" error here in the code?
Comment 3 Don 2009年08月15日 11:22:05 UTC
(In reply to comment #2)
> What bug reports are there already for the fact that we have a "has forward
> references" error here in the code?
I don't think there are any. This is a very simple regression, caused by a typo. It's unrelated to other forward reference errors.
Comment 4 Stewart Gordon 2009年08月15日 12:23:39 UTC
(In reply to comment #3)
> (In reply to comment #2)
> > What bug reports are there already for the fact that we have a "has forward
> > references" error here in the code?
> 
> I don't think there are any. This is a very simple regression, caused by a
> typo. It's unrelated to other forward reference errors.
Maybe, but it's clearly related to at least one other cause of the same forward reference error. If it weren't, then any fix to this bug would cause the line
 error("has forward references");
to disappear completely.
So it's a matter of figuring out what else triggers this error.
Comment 5 Walter Bright 2009年09月03日 13:29:20 UTC
Fixed dmd 1.047


AltStyle によって変換されたページ (->オリジナル) /