[Issue 11881] New: -betterC switch suffers from bit rot
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Tue Jan 7 18:57:51 PST 2014
https://d.puremagic.com/issues/show_bug.cgi?id=11881
Summary: -betterC switch suffers from bit rot
Product: D
Version: D2
Platform: All
OS/Version: All
Status: NEW
Severity: normal
Priority: P2
Component: DMD
AssignedTo: nobody at puremagic.com
ReportedBy: bugzilla at digitalmars.com
--- Comment #0 from Walter Bright <bugzilla at digitalmars.com> 2014-01-07 18:57:47 PST ---
Adam D. Ruppe writes:
I find the -betterC switch to be totally useless. If you are just toying,
there's no module info anyway:
extern(C) {
void _d_run_main() {} // why is this required now????
void* _d_dso_registry;
void _start() {
}
}
dmd -c *.d -defaultlib= -debuglib=
gcc -m32 *.o -nostdlib
success. Add "struct Test{}" and:
Error: ModuleInfo not found. object.d may be incorrectly installed or corrupt.
OK, add -betterC:
Error: TypeInfo not found. object.d may be incorrectly installed or corrupt,
compile with -v switch
If you do use an object.d with it defined to get past the compiler, it doesn't
help much as the linker complains anyway:
test.o:(.data._D20TypeInfo_S4test4Test6__initZ+0x0): undefined reference to
`_D15TypeInfo_Struct6__vtblZ'
So my verdict is -betterC is pretty useless. If it got past the TypeInfo stuff
the same way it gets past ModuleInfo though, then we'd be cooking with gas.
That potentially gives a language that is legitimately a better C. But without
structs, bah.
This is a filthy hack, but it is easy to change this in the compiler. (Isn't
-betterC a filthy hack in the first place anyway :) )
In
Expression *Type::getTypeInfo(Scope *sc)
Add
if(global.params.betterC)
return NULL;
right to the top.
And same for struct decl
void TypeInfoStructDeclaration::toDt(dt_t **pdt)
{
if(global.params.betterC)
return;
Then it compiles with the struct! ~5 KB executable, two line object.d.
....but adding some methods to the struct complain about missing ModuleInfo
again. Looks like it wants to do assert(this !is null); and the assert thing
takes a module info reference.
Ugh.... that said, adding:
void _d_assert_msg() {}
void _d_assertm() {}
void* _D4test12__ModuleInfoZ;
to my extern(C) boilerplate did manage to work - structs with postblits and
dtors yay! - and trimmed the exe down to 1.3K.
Maybe -betterC can stop outputting those references too and then we'd really be
cooking.
--
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list