www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Funny way to crash dmd and brick the whole computer

reply Zardoz <luis.panadero gmail.com> writes:
CTE fib :

module fib_cte;
import std.stdio;

long fib(long n) {
   if (n <= 1) return 1;
   return fib(n - 1) + fib(n - 2);
}

static immutable valueFib = fib(46);

void main() {
     writeln(valueFib);
}
Sep 28 2018
next sibling parent Stefan Koch <uplink.coder googlemail.com> writes:
On Friday, 28 September 2018 at 11:58:25 UTC, Zardoz wrote:
 CTE fib :

 module fib_cte;
 import std.stdio;

 long fib(long n) {
   if (n <= 1) return 1;
   return fib(n - 1) + fib(n - 2);
 }

 static immutable valueFib = fib(46);

 void main() {
     writeln(valueFib);
 }
to be fair, that function is incredibly inefficient. when you write an iterative fibonacci-series generator, it'll work.
Sep 28 2018
prev sibling next sibling parent Norm <norm.rowtree gmail.com> writes:
On Friday, 28 September 2018 at 11:58:25 UTC, Zardoz wrote:
 CTE fib :

 module fib_cte;
 import std.stdio;

 long fib(long n) {
   if (n <= 1) return 1;
   return fib(n - 1) + fib(n - 2);
 }

 static immutable valueFib = fib(46);

 void main() {
     writeln(valueFib);
 }
This isn't a brick, this is your OS not handling lack of resources. A brick is when the machine will no longer boot without some physical intervention like JTAGing or replacing parts. DMD sacrifices memory for speed so it is not surprising given that code abomination. bye, norm
Sep 28 2018
prev sibling next sibling parent bauss <jj_1337 live.dk> writes:
On Friday, 28 September 2018 at 11:58:25 UTC, Zardoz wrote:
 CTE fib :

 module fib_cte;
 import std.stdio;

 long fib(long n) {
   if (n <= 1) return 1;
   return fib(n - 1) + fib(n - 2);
 }

 static immutable valueFib = fib(46);

 void main() {
     writeln(valueFib);
 }
What exactly did you expect?
Sep 29 2018
prev sibling next sibling parent reply Basile B. <b2.temp gmx.com> writes:
On Friday, 28 September 2018 at 11:58:25 UTC, Zardoz wrote:
 CTE fib :

 module fib_cte;
 import std.stdio;

 long fib(long n) {
   if (n <= 1) return 1;
   return fib(n - 1) + fib(n - 2);
 }

 static immutable valueFib = fib(46);

 void main() {
     writeln(valueFib);
 }
don't try to compile this one linux: ``` void main(){ asm{ db cast(ubyte[]) "é"; } } ```
Oct 01 2018
parent reply Basile B. <b2.temp gmx.com> writes:
On Monday, 1 October 2018 at 09:24:18 UTC, Basile B. wrote:
 On Friday, 28 September 2018 at 11:58:25 UTC, Zardoz wrote:
 CTE fib :

 module fib_cte;
 import std.stdio;

 long fib(long n) {
   if (n <= 1) return 1;
   return fib(n - 1) + fib(n - 2);
 }

 static immutable valueFib = fib(46);

 void main() {
     writeln(valueFib);
 }
don't try to compile this one linux: ``` void main(){ asm{ db cast(ubyte[]) "é"; } } ```
Actually no, it's an IDE issue triggered by this code.
Oct 01 2018
parent reply bauss <jj_1337 live.dk> writes:
On Monday, 1 October 2018 at 10:18:48 UTC, Basile B. wrote:
 On Monday, 1 October 2018 at 09:24:18 UTC, Basile B. wrote:
 On Friday, 28 September 2018 at 11:58:25 UTC, Zardoz wrote:
 CTE fib :

 module fib_cte;
 import std.stdio;

 long fib(long n) {
   if (n <= 1) return 1;
   return fib(n - 1) + fib(n - 2);
 }

 static immutable valueFib = fib(46);

 void main() {
     writeln(valueFib);
 }
don't try to compile this one linux: ``` void main(){ asm{ db cast(ubyte[]) "é"; } } ```
Actually no, it's an IDE issue triggered by this code.
In what world should an IDE ever have an issue with the code you write?
Oct 02 2018
parent Basile B. <b2.temp gmx.com> writes:
On Tuesday, 2 October 2018 at 07:18:32 UTC, bauss wrote:
 don't try to compile this one linux:

 ```
 void main(){  asm{ db cast(ubyte[]) "é"; }  }
 ```
Actually no, it's an IDE issue triggered by this code.
In what world should an IDE ever have an issue with the code you write?
It's a dparse bug : https://github.com/dlang-community/libdparse/issues/278. In the IDE when I execute the action "Compile module and run" several things happen which require to lex and parse the "runnable" module with dparse. 1. AST is visited to determine if "-main" have to be passed or not to the compiler: https://github.com/BBasile/Coedit/blob/master/dastworx/src/mainfun.d#L22 2. Imports are enumerated : https://github.com/BBasile/Coedit/blob/master/dastworx/src/imports.d#L23. The list is used to get their matching source path and static library file, which are passed to the compiler automatically (https://github.com/BBasile/Coedit/blob/master/src/ce_libman.pas#L125). <mode |= Mode.arrogant> Have you ever dreamed to have a system that solve dependencies without specifying them in a DUB embedded receipt or JSON/SDL ? I did it. <mode &= ~Mode.arrogant>
Oct 02 2018
prev sibling parent Joakim <dlang joakim.fea.st> writes:
On Friday, 28 September 2018 at 11:58:25 UTC, Zardoz wrote:
 CTE fib :

 module fib_cte;
 import std.stdio;

 long fib(long n) {
   if (n <= 1) return 1;
   return fib(n - 1) + fib(n - 2);
 }

 static immutable valueFib = fib(46);

 void main() {
     writeln(valueFib);
 }
I tried it on Android with LDC, it eventually just kills the process. You need to get a real OS. ;)
Oct 01 2018