Discussion:
When betterC triggers errors in compilation?
eles via Digitalmars-d-learn
2014-10-14 13:20:49 UTC
Permalink
Hello,

According to this:

http://forum.dlang.org/post/lddug4$jgv$***@digitalmars.com

"-betterC" should disable support for exception handling. So I
expected dmd to reject the following code:

===============================================
import std.stdio;

int readDieFromFile()
{
auto file = File("the_file_that_contains_the_value", "r");

int die;
file.readf(" %s", &die);

return die;
}

int tryReadingFromFile()
{
int die;

try {
die = readDieFromFile();

} catch (std.exception.ErrnoException exc) {
writeln("(Could not read from file; assuming 1)");
die = 1;
}

return die;
}

void main()
{
const int die = tryReadingFromFile();

writeln("Die value: ", die);
}
=======================================================
(from Ali's book; thanks once again)

But it compiles and runs fine:

$dmd betterC.d -betterC

$./betterC
(Could not read from file; assuming 1)
Die value: 1

This is with dmd 2.066 on Linux x86_64.

What code would fail under -betterC and how?
Adam D. Ruppe via Digitalmars-d-learn
2014-10-14 13:31:46 UTC
Permalink
That was just a speculative thread, that stuff isn't implemented.
(And I think that went way too far, IMO betterC should just
remove the mandatory stuff like ModuleInfo and TypeInfo
assumptions and leave the rest to be opt in. I'd be against it
making exception handling an error).

-betterC right now is still an undocumented hack that doesn't do
much.
eles via Digitalmars-d-learn
2014-10-14 13:45:31 UTC
Permalink
Post by Adam D. Ruppe via Digitalmars-d-learn
-betterC right now is still an undocumented hack that doesn't
do much.
Thank you.

ketmar via Digitalmars-d-learn
2014-10-14 13:46:37 UTC
Permalink
On Tue, 14 Oct 2014 13:20:49 +0000
Post by eles via Digitalmars-d-learn
What code would fail under -betterC and how?
currently betterC disables module info generation and some module
helper functions generation. that's all. just grep DMD sources for
"betterC" and you'll see it.
Loading...