diff --git a/1996/august/.gitignore b/1996/august/.gitignore index 5a6a66fc5..0b5694ffe 100644 --- a/1996/august/.gitignore +++ b/1996/august/.gitignore @@ -4,3 +4,5 @@ test.oo fac.oo parse.oo prog.oc +august.oo +prog.oo diff --git a/1996/august/Makefile b/1996/august/Makefile index eac9f9e19..3200372aa 100644 --- a/1996/august/Makefile +++ b/1996/august/Makefile @@ -38,7 +38,7 @@ include ../../var.mk # Common C compiler warnings to silence # -CSILENCE= -Wno-error -Wno-implicit-function-declaration -Wno-invalid-source-encoding +CSILENCE= -Wno-error -Wno-implicit-function-declaration -Wno-invalid-source-encoding -Wno-invalid-utf8 # Common C compiler warning flags # @@ -57,7 +57,7 @@ ARCH= # Defines that are needed to compile # -CDEFINE= -DZ=60000 -D'T=m[s]' -D'P=m[s++]' \ +CDEFINE= -DZ=240000 -D'T=m[s]' -D'P=m[s++]' \ -D'L=m[p++]' -D'g=getchar()' -DE=else -DW=while -D'B=m[p++]' \ -DI=if -DR='s=s+l/2;T=r;I(l%2)s++' -D'X=m[s-' \ -D'D=Q(13,-)Q(14,*)Q(15,/)Q(16,%)Q(6,==)Q(7,!=)Q(8,<)C(1,r=P;m[T]=r;T=r)C(9,r=P;m[T]=r;s++)' diff --git a/1996/august/README.md b/1996/august/README.md index 435850d55..6161d5eb5 100644 --- a/1996/august/README.md +++ b/1996/august/README.md @@ -20,12 +20,22 @@ cat august.c test.oc | ./august > test.oo ``` -NOTE: Some compilers will compile this code into infinite loops! -If the above cat line does not execute in a very short amount -of time, then you may need to fix your compiler or use gcc. +NOTE: Some compilers like clang will compile this code into infinite loops! If +the above cat line (or one of the ones later in the try section) does not +execute in a very short amount of time, then you may need to fix your compiler +or use gcc. -It should print a `!` followed by a newline. +The above should print a `!` followed by a newline. +[Cody Boone Ferguson](/winners.html#Cody_Boone_Ferguson) fixed a segfault in +this program that prevented it from working right but he notes it hangs in +macOS. It works fine in linux. This is because macOS has clang, not gcc, even +the gcc binary. He observed that with specific compiler flags it hangs in linux +too and perhaps it's related to this in macOS; maybe other flags are needed but +he doesn't know (at least not yet). He provided a bit more information in +[bugs.md](/bugs.md) for anyone who wants to have a go at providing a fix for +other compilers. As there are a lot of commands to try he also added +[try.sh](try.sh). Thank you Cody for your assistance! ## Try: @@ -75,6 +85,13 @@ And if you have lots of spare time, you can recurse one level deeper: cat august.oo august.oo august.oo fac.oo | ./august ``` +NOTE: to run all the commands in the above sections you can also use the +[try.sh](try.sh) script like: + +```sh +./try.sh +``` + We (the judges) recommend that you spend some time studying this entry as it surely will make the 'best of the IOCCC' list. It was very well received by those who attended the IOCCC BOF. diff --git a/1996/august/try.sh b/1996/august/try.sh new file mode 100755 index 000000000..58c968a75 --- /dev/null +++ b/1996/august/try.sh @@ -0,0 +1,20 @@ +#!/usr/bin/env bash + +make clobber all +set -x +cat august.c test.oc | ./august > test.oo +./august < test.oo +cat august.c fac.oc | ./august > fac.oo +./august < fac.oo + +cat august.c fac.oc | ./august | ./august + +cat august.c parse.oc | ./august > parse.oo +cat parse.oo fac.oc | ./august | ./august + +rm august.oc +make august.oc +cat august.c august.oc | ./august > august.oo +cat august.oo test.oo | ./august +cat august.oo august.oo fac.oo | ./august +cat august.oo august.oo august.oo fac.oo | ./august diff --git a/bugs.md b/bugs.md index 88fe74699..961e5d5be 100644 --- a/bugs.md +++ b/bugs.md @@ -800,6 +800,36 @@ We would appreciate anyone who has it or even just knows the name! Thank you. # 1996 +## [1996/august](1996/august/august.c) ([README.md](1996/august/README.md)) +## STATUS: doesn't work with some compilers - please provide alternative code + +[Cody Boone Ferguson](/winners.html#Cody_Boone_Ferguson) fixed a segfault in +this program that prevented it from working but he observes that this hangs +in macOS with this invocation in particular: + +```sh +cat august.c august.oc | ./august > august.oo +``` + +This happens to do with the fact that macOS is `clang` even the binary `gcc`. +Trying clang in linux and the same problem occurs. As well if specifying (even +with gcc) certain flags this also happens namely `-ggdb3`. The bug fix involved +increasing the value of `Z` as it was accessing way out of range of the array, +thus causing a segfault. + +The compilation should look like: + +```sh +cc -std=gnu90 -Wall -Wextra -pedantic -Wno-error -Wno-implicit-function-declaration -Wno-invalid-source-encoding -Wno-invalid-utf8 -DZ=240000 -D'T=m[s]' -D'P=m[s++]' -D'L=m[p++]' -D'g=getchar()' -DE=else -DW=while -D'B=m[p++]' -DI=if -DR='s=s+l/2;T=r;I(l%2)s++' -D'X=m[s-' -D'D=Q(13,-)Q(14,*)Q(15,/)Q(16,%)Q(6,==)Q(7,!=)Q(8,<)C(1,r=P;m[T]=r;T=r)C(9,r=P;m[T]=r;s++)' -O3 august.c -o august +``` + +but again this will not work with clang. As the judges noted that some compilers +compile it into an infinite loop I'm (Cody) inclined to believe that this is the +source of the problem. + +Nevertheless if you have a fix for clang we welcome it! + + ## [1996/gandalf](1996/gandalf/gandalf.c) ([README.md](1996/gandalf/README.md)) ## STATUS: missing or dead link - please provide them