Bug 3168 – Declaring structs as incomplete types no longer works

Status
RESOLVED
Resolution
FIXED
Severity
regression
Priority
P2
Component
dmd
Product
D
Version
D1 (retired)
Platform
All
OS
All
Creation time
2009-07-12T08:48:00Z
Last change time
2014-04-18T09:12:06Z
Keywords
patch, rejects-valid
Assigned to
nobody
Creator
nfxjfg

Comments

Comment #0 by nfxjfg — 2009-07-12T08:48:16Z
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 by clugdbug — 2009-08-06T13:08:07Z
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 by smjg — 2009-08-15T06:31:57Z
What bug reports are there already for the fact that we have a "has forward references" error here in the code?
Comment #3 by clugdbug — 2009-08-15T11:22:05Z
(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 by smjg — 2009-08-15T12:23:39Z
(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 by bugzilla — 2009-09-03T13:29:20Z
Fixed dmd 1.047