The contest goal is simple:
1. Create a program of no more than five lines, with no line over 80
characters.
2. Compile the program with gcc with as many warning flags on as you want.
3. Get the largest possible number of warnings without getting a single
error.
The program need not be strictly conforming C, but it must pass the "that
looks like C" test administered by a small panel of experienced C programmers.
You may not specifically coerce errors into warnings; you may enable warnings,
but you may not disable errors with compiler flags. "Lines" and "characters"
will be counted by a text editor, not a compiler, so backslashes, preprocessor
directives, and other magic don't change the line count.
If you use header files, be aware that the official count may be performed
on a different system, so don't rely too heavily on the contents of header
files.
Send your entries to me by November 5, 2005. There will be some sort of
prize, but until I see the entries, I won't know how horrible to make it.
-s
--
Copyright 2005, all wrongs reversed. Peter Seebach / se...@plethora.net
http://www.seebs.net/log/ - YA blog. http://www.seebs.net/ - homepage.
C/Unix wizard, pro-commerce radical, spam fighter. Boycott Spamazon!
Consulting, computers, web hosting, and shell access: http://www.plethora.net/
--
comp.lang.c.moderated - moderation address: cl...@plethora.net -- you must
have an appropriate newsgroups line in your header for your mail to be seen,
or the newsgroup name in square brackets in the subject line. Sorry.
> Okay, this will be nicely trivial.
>
> The contest goal is simple:
>
> 1. Create a program of no more than five lines, with no line over 80
> characters.
#define A "%llu%llu%llu%llu%llu%llu%llu%llu%llu%llu%llu%llu%llu%llu%llu%llu%llu"
#define B 1/0,1/0,1/0,1/0,1/0,1/0,1/0,1/0,1/0,1/0,1/0,1/0,1/0,1/0,1/0,1/0,1/0,-1
main(){printf(A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A
A A A A A A A A A A A A A A A A A A A A A A A A,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,
B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B);}
> 2. Compile the program with gcc with as many warning flags on as you want.
-std=c89 -pedantic -Wall -W -Wtraditional -Wlarger-than-2 -Wstrict-prototypes
> 3. Get the largest possible number of warnings without getting a single
> error.
2881 warnings (2882 if you count "In function 'main':") from gcc 3.3.6 on a
gentoo/x86 machine.
Different warnings? I think it might be better to do more than just
count the number of warnings.
>
>The program need not be strictly conforming C, but it must pass the "that
>looks like C" test administered by a small panel of experienced C programmers.
>
>You may not specifically coerce errors into warnings; you may enable warnings,
>but you may not disable errors with compiler flags. "Lines" and "characters"
>will be counted by a text editor, not a compiler, so backslashes, preprocessor
>directives, and other magic don't change the line count.
>
>If you use header files, be aware that the official count may be performed
>on a different system, so don't rely too heavily on the contents of header
>files.
Do standard header files count as 1 line?
--
Francis Glassborow ACCU
Author of 'You Can Do It!' see http://www.spellen.org/youcandoit
For project ideas and contributions: http://www.spellen.org/youcandoit/projects
DISTINCT warnings.
Several million instances of the same warning doesn't count, so any program
with
#define a b b b b b b b b ...
is not going to help you much. :)
> Seebs wrote:
>
>> Okay, this will be nicely trivial.
>>
>> The contest goal is simple:
>>
>> 1. Create a program of no more than five lines, with no line over 80
>> characters.
>
> #define A "%llu%llu%llu%llu%llu%llu%llu%llu%llu%llu%llu%llu%llu%llu%llu%llu%llu"
> #define B 1/0,1/0,1/0,1/0,1/0,1/0,1/0,1/0,1/0,1/0,1/0,1/0,1/0,1/0,1/0,1/0,1/0,-1
> main(){printf(A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A
> A A A A A A A A A A A A A A A A A A A A A A A A,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,
> B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B);}
>
>> 2. Compile the program with gcc with as many warning flags on as you want.
>
> -std=c89 -pedantic -Wall -W -Wtraditional -Wlarger-than-2 -Wstrict-prototypes
>
>> 3. Get the largest possible number of warnings without getting a single
>> error.
>
> 2881 warnings (2882 if you count "In function 'main':") from gcc 3.3.6 on a
> gentoo/x86 machine.
You're thinking too small. I entered one (but it only had one kind of
warning), which I'll repeat here. It has about 10^16308 errors (I counted
them... :-) :
#define R(A) A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A
#define S(A) R(R(R(R(R(R(R(R(R(R(R(R(R(R(R(R(R(R(R(R(R(R(A))))))))))))))))))))))
#define T(A) S(S(S(S(S(S(S(S(S(S(S(S(S(S(S(S(S(S(S(S(S(S(A))))))))))))))))))))))
#define U(A) T(T(T(T(T(T(T(T(T(T(T(T(T(T(T(T(T(T(T(T(T(T(A))))))))))))))))))))))
float main(){int a=0,*b;S(b=a);S(b=a);S(b=a);S(b=a);S(b=a);S(b=a);S(b=a);S(b=a)}
Errors generated with no flags. To get an extra 2 warnings, use -Wall on
GCC.
-Ed
--
(You can't go wrong with psycho-rats.) (er258)(@)(eng.cam)(.ac.uk)
/d{def}def/f{/Times findfont s scalefont setfont}d/s{10}d/r{roll}d f 5/m
{moveto}d -1 r 230 350 m 0 1 179{1 index show 88 rotate 4 mul 0 rmoveto}
for /s 15 d f pop 240 420 m 0 1 3 { 4 2 1 r sub -1 r show } for showpage
Ugh. That's changing the rules :-) Anyway, now that my two hour
investment is no longer a contender, I might as well post a five
liner with a bunch of warnings here. Just for the fun of it, I hereby
start a similar contest, where each warning counts, even the same.
Your prize is the honor of beating my entry :-O
$ cat warns.c
#define Z a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,I\
,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,_0,_1,_2,_3,_4,_5,_6,_7,_8,_9,_a,_b,_c,_d,_e,_f
#define _(x)x##_(Z){int _=(Z=(Z=(Z=(Z=(Z=(Z=(Z=(Z=(Z=(Z=(Z=(Z=(Z=(Z=(Z=(Z=(Z=(Z\
=(Z=(Z=(Z=(Z=(Z=(Z=(Z=(Z=(Z=(Z=(Z=(Z=(Z=(Z=(Z)))))))))))))))))))))))))))))))));}
_(A)_(B)_(C)_(D)_(E)_(F)_(G)_(H)_(I)_(J)_(K)_(L)_(M)_(N)_(O)_(P)_(Q)_(R)_(S)_(T)
$ gcc -v
Using built-in specs.
Configured with: FreeBSD/i386 system compiler
Thread model: posix
gcc version 3.4.4 [FreeBSD] 20050518
$ gcc -O -Wall -ansi -pedantic -Wold-style-definition -Wextra -Wmissing-declarations -c -o foo warns.c >log 2>&1
$ grep -c error: log
0
$ grep -c warning: log
What do you think that will print? Guess.
Nope, waaaaay off. Guess again, but higher.
Alright. Last chance to guess.
45000
That's exactly 9000 warnings per line, or 111+1/9 warnings per character,
or almost 14 warnings per *bit* on your 8bit box, on average!
Regards,
Jens
--
Jens Schweikhardt http://www.schweikhardt.net/
SIGSIG -- signature too long (core dumped)
#define _){int*i;return&i;x+++x;}struct a{}main(b,c)struct a
b;unsigned char c;
const extern enum i{i=(int)(-1U/2)};extern x=0;static
f(_{return+1+i+100000000\
00000000000LL/0*1e99f,b=main(b,'\e\c'>>64);switch(c)case-i:case+i:if(c=i||main&\
&0)if(1);else;enum i i;switch(i)case 0:;execl(strlen(0),realloc());int
x;x:f();}
int abs;struct a main(struct a,int);inline
f(void);g(enum{x});h(){printf("%!");}
(Note that there's one leading space on line 1, and one trailing space
on line 2. All lines are exactly 80 chars, in case it's not clear
because of word wrapping.)
Compiled with gcc-4.0.2 -pedantic -Wall -Wextra -Waggregate-return
-Wlarger-than-4 -Wnested-externs -Wold-style-definition
-Wredundant-decls -Wshadow -Wstrict-prototypes -Wswitch-default
-Wtraditional -Wunreachable-code on an x86 Linux system, with duplicate
warnings removed (I am not sure what does and doesn't count as
duplicate; some are arguable), this gives 62 warnings. It compiles (and
links) without errors when no special options are given.
warn.c:1:3: warning: traditional C ignores #define with the # indented
warn.c:1:11: warning: missing whitespace after the macro name
warn.c:2: warning: ‘extern’ is not at beginning of declaration
warn.c:2:30: warning: traditional C rejects the "U" suffix
warn.c:2: warning: useless storage class specifier in empty declaration
warn.c:2: warning: type defaults to ‘int’ in declaration of ‘x’
warn.c:2: warning: ‘x’ initialized and declared ‘extern’
warn.c:2: warning: function declaration isn’t a prototype
warn.c:2: warning: old-style function definition
warn.c:2: warning: declaration of ‘i’ shadows a global declaration
warn.c:2: warning: shadowed declaration is here
warn.c:2: warning: return makes integer from pointer without a cast
warn.c:2: warning: function returns address of local variable
warn.c:2: warning: operation on ‘x’ may be undefined
warn.c:2: warning: will never be executed
warn.c:2: warning: struct has no members
warn.c:2: warning: return type of ‘main’ is not ‘int’
warn.c:2: warning: traditional C rejects the unary plus operator
warn.c:2: warning: integer overflow in expression
warn.c:2:70: warning: traditional C rejects the "LL" suffix
warn.c:2:70: warning: use of C99 long long integer constant
warn.c:2:70: warning: integer constant is so large that it is unsigned
warn.c:2: warning: this decimal constant is unsigned only in ISO C90
warn.c:2:79: warning: backslash and newline separated by space
warn.c:2: warning: division by zero
warn.c:3:17: warning: traditional C rejects the "f" suffix
warn.c:2: warning: floating constant exceeds range of ‘float’
warn.c:3:32: warning: non-ISO-standard escape sequence, '\e'
warn.c:3:32: warning: unknown escape sequence '\c'
warn.c:3:32: warning: multi-character character constant
warn.c:2: warning: right shift count >= width of type
warn.c:2: warning: left-hand operand of comma expression has no effect
warn.c:2: warning: case label value is less than minimum value for type
warn.c:2: warning: case label value exceeds maximum value for type
warn.c:2: warning: the address of ‘main’, will always evaluate as
‘true’
warn.c:2: warning: suggest parentheses around && within ||
warn.c:2: warning: suggest parentheses around assignment used as truth
value
warn.c:2: warning: empty body in an else-statement
warn.c:2: warning: suggest explicit braces to avoid ambiguous
‘else’
warn.c:2: warning: switch missing default case
warn.c:2: warning: ISO C90 forbids mixed declarations and code
warn.c:2: warning: enumeration value ‘i’ not handled in switch
warn.c:2: warning: case value ‘0’ not in enumerated type ‘enum
i’
warn.c:2: warning: implicit declaration of function ‘execl’
warn.c:2: warning: incompatible implicit declaration of built-in
function ‘execl’
warn.c:2: warning: null argument where non-null required (argument 1)
warn.c:2: warning: nested extern declaration of ‘realloc’
warn.c:2: warning: not enough variable arguments to fit a sentinel
warn.c:2: warning: traditional C lacks a separate namespace for labels,
identifier ‘x’ conflicts
warn.c:2: warning: label ‘x’ defined but not used
warn.c:2: warning: unused variable ‘x’
warn.c:2: warning: size of ‘({anonymous})’ is 8 bytes
warn.c:2: warning: function returns an aggregate
warn.c:2: warning: function call has aggregate value
warn.c:5: warning: built-in function ‘abs’ declared as non-function
warn.c:5: warning: prototype for ‘main’ follows non-prototype
definition
warn.c:5: warning: redundant redeclaration of ‘main’
warn.c:2: warning: previous definition of ‘main’ was here
warn.c:5: warning: non-static declaration of ‘f’ follows static
declaration
warn.c:2: warning: ‘f’ declared inline after being called
warn.c:2: warning: previous definition of ‘f’ was here
warn.c:5: warning: anonymous enum declared inside parameter list
warn.c:5: warning: its scope is only this definition or declaration,
which is probably not what you want
warn.c:5: warning: data definition has no type or storage class
warn.c:5: warning: unknown conversion type character ‘!’ in format
warn.c:5: warning: control reaches end of non-void function
There are still obvious things that could still be improved though.
Yes, I was. This is better (28568 with the same flags as before):
#define A "%llu%llu%llu%llu%llu%llu%llu%llu%llu%llu%llu%llu%llu%llu%llu%llu%llu"
#define a A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A
#define B 1/0,1/0,1/0,1/0,1/0,1/0,1/0,1/0,1/0,1/0,1/0,1/0,1/0,1/0,1/0,1/0,1/0,-1
#define b B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B
main(){printf(a a a a a a a a a a a a a a a a,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b);}
But it still has only 9530 unique warnings (OK so it's only 11 if you ignore the
difference in argument number for the format warning).
> It has about 10^16308 errors (I counted them... :-) :
>
> #define R(A) A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A
> #define S(A) R(R(R(R(R(R(R(R(R(R(R(R(R(R(R(R(R(R(R(R(R(R(A))))))))))))))))))))))
> #define T(A) S(S(S(S(S(S(S(S(S(S(S(S(S(S(S(S(S(S(S(S(S(S(A))))))))))))))))))))))
> #define U(A) T(T(T(T(T(T(T(T(T(T(T(T(T(T(T(T(T(T(T(T(T(T(A))))))))))))))))))))))
> float main(){int a=0,*b;S(b=a);S(b=a);S(b=a);S(b=a);S(b=a);S(b=a);S(b=a);S(b=a)}
>
> Errors generated with no flags. To get an extra 2 warnings, use -Wall on
> GCC.
OP wanted the maximum warning count with _no_ errors. And surely you meant to
use your T and U macros somewhere?
>#define Z a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,I\
>,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,_0,_1,_2,_3,_4,_5,_6,_7,_8,_9,_a,_b,_c,_d,_e,_f
>#define _(x)x##_(Z){int _=(Z=(Z=(Z=(Z=(Z=(Z=(Z=(Z=(Z=(Z=(Z=(Z=(Z=(Z=(Z=(Z=(Z=(Z\
>=(Z=(Z=(Z=(Z=(Z=(Z=(Z=(Z=(Z=(Z=(Z=(Z=(Z=(Z=(Z)))))))))))))))))))))))))))))))));}
>_(A)_(B)_(C)_(D)_(E)_(F)_(G)_(H)_(I)_(J)_(K)_(L)_(M)_(N)_(O)_(P)_(Q)_(R)_(S)_(T)
gcc -std=c89 -pedantic -Wall -W -Wtraditional -Wlarger-than-2 -Wstrict-prototypes warn.c
I get 46,399 - impressive.
--
#include <standard.disclaimer>
_
Kevin D Quitt USA 91387-4454 96.37% of all statistics are made up
<snip contest stuff>
> That's exactly 9000 warnings per line, or 111+1/9 warnings per
character,
> or almost 14 warnings per *bit* on your 8bit box, on average!
Warnings per bit (wpb)...
Is that a Microsoft metric?
--
Mabden
#define Z a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,I,J
#define _(x)x##_(Z){int _=(Z=(Z=(Z=(Z=(Z=(Z=(Z=(Z=(Z=(Z=(Z=(Z=(Z)))))))))))));}
#define X(x)_(x##A)_(x##B)_(x##C)_(x##D)_(x##E)_(x##F)_(x##G)_(x##H)_(x##I)
#define Y(x)X(x##A)X(x##B)X(x##C)X(x##D)X(x##E)X(x##F)X(x##G)X(x##H)X(x##I)
Y(a)Y(b)Y(c)Y(d)Y(e)Y(f)Y(g)Y(h)Y(i)Y(j)Y(k)Y(l)Y(m)Y(n)Y(o)Y(p)Y(q)Y(r)Y(s)Y(t)
Using gcc 3.4.4 and the same flags as previous examples.
Yes, Line one is 81 chars, but other lines are shorter; this generates 803520 warnings.
If we can't have the ,J then we only get 780840.
Of those, 1651 are textually unique, and 7 different warnings.
--
#include <standard.disclaimer>
_
Kevin D Quitt USA 91387-4454 96.37% of all statistics are made up
> E. Rosten wrote:
>> You're thinking too small.
>
> Yes, I was. This is better (28568 with the same flags as before):
>
> #define A "%llu%llu%llu%llu%llu%llu%llu%llu%llu%llu%llu%llu%llu%llu%llu%llu%llu"
> #define a A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A
> #define B 1/0,1/0,1/0,1/0,1/0,1/0,1/0,1/0,1/0,1/0,1/0,1/0,1/0,1/0,1/0,1/0,1/0,-1
> #define b B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B
> main(){printf(a a a a a a a a a a a a a a a a,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b);}
>
> But it still has only 9530 unique warnings (OK so it's only 11 if you ignore the
> difference in argument number for the format warning).
True. I invented mine before it was restricted to unique warnings. Nice
trick making them unique with the argument number.
>> It has about 10^16308 errors (I counted them... :-) :
>>
>> #define R(A) A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A
>> #define S(A) R(R(R(R(R(R(R(R(R(R(R(R(R(R(R(R(R(R(R(R(R(R(A))))))))))))))))))))))
>> #define T(A) S(S(S(S(S(S(S(S(S(S(S(S(S(S(S(S(S(S(S(S(S(S(A))))))))))))))))))))))
>> #define U(A) T(T(T(T(T(T(T(T(T(T(T(T(T(T(T(T(T(T(T(T(T(T(A))))))))))))))))))))))
>> float main(){int a=0,*b;S(b=a);S(b=a);S(b=a);S(b=a);S(b=a);S(b=a);S(b=a);S(b=a)}
>>
>> Errors generated with no flags. To get an extra 2 warnings, use -Wall on
>> GCC.
>
> OP wanted the maximum warning count with _no_ errors.
Theoretically, it is compliant, so it should compile. However, the
compilers tens to exit with a core dump, so it's not really an error in my
C code. But one can't help it if one's compiler can't cope...
The float main is optional. On GCC, it gives 2 extra warnings. On balance,
it can be omitted, however, since the extra 2 warnings mighe generate an
error on some compilers and don't really have much of an overall effect.
> And surely you meant to
> use your T and U macros somewhere?
The last line is meant to reat U(b=a), etc, not S(b=a), otherwise it gives
a measly 10^38 errors.
-Ed
--
(You can't go wrong with psycho-rats.) (er258)(@)(eng.cam)(.ac.uk)
/d{def}def/f{/Times findfont s scalefont setfont}d/s{10}d/r{roll}d f 5/m
{moveto}d -1 r 230 350 m 0 1 179{1 index show 88 rotate 4 mul 0 rmoveto}
for /s 15 d f pop 240 420 m 0 1 3 { 4 2 1 r sub -1 r show } for showpage
Might I ask on what system you are compiling this? I get nothing but core dumps.
--
#include <standard.disclaimer>
_
Kevin D Quitt USA 91387-4454 96.37% of all statistics are made up
Cool! Note that with gcc you can always sprinkle a few semicolons at
file scope for extra warnings. If you use this "feature" to fill the
lines less than 80 chars, e.g (obeying the 80 chars rule) with
#define Z a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,I
#define _(x)x##_(Z){int _=(Z=(Z=(Z=(Z=(Z=(Z=(Z=(Z=(Z=(Z=(Z=(Z=(Z)))))))))))));};
#define X(x)_(x##A)_(x##B)_(x##C)_(x##D)_(x##E)_(x##F)_(x##G)_(x##H)_(x##I);;;;;
#define Y(x)X(x##A)X(x##B)X(x##C)X(x##D)X(x##E)X(x##F)X(x##G)X(x##H)X(x##I);;;;;
Y(a)Y(b)Y(c)Y(d)Y(e)Y(f)Y(g)Y(h)Y(i)Y(j)Y(k)Y(l)Y(m)Y(n)Y(o)Y(p)Y(q)Y(r)Y(s)Y(t)
we have
$ gcc -std=c89 -pedantic -Wall -W -Wtraditional -Wlarger-than-2 \
-Wstrict-prototypes -c warns.c 2>&1|grep warning:|wc -l
841780
$ gcc -std=c89 -pedantic -Wall -W -Wtraditional -Wlarger-than-2 \
-Wstrict-prototypes -c warns.c 2>&1|grep error:
$ gcc -v
Using built-in specs.
Configured with: FreeBSD/i386 system compiler
Thread model: posix
gcc version 3.4.4 [FreeBSD] 20050518
And all the 841780 warnings refer to the same line... A sharp look at the
naive ;-padding makes us realize there's more opportunity for warnings, e.g.
#define Z a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,I
#define _(x);x##_(Z){int _=(Z=(Z=(Z=(Z=(Z=(Z=(Z=(Z=(Z=(Z=(Z=(Z=(Z)))))))))))));}
#define X(x)_(x##A)_(x##B)_(x##C)_(x##D)_(x##E)_(x##F)_(x##G)_(x##H)_(x##I)int Z
#define Y(x)X(x##A)X(x##B)X(x##C)X(x##D)X(x##E)X(x##F)X(x##G)X(x##H)X(x##I);;;;;
Y(a)Y(b)Y(c)Y(d)Y(e)Y(f)Y(g)Y(h)Y(i)Y(j)Y(k)Y(l)Y(m)Y(n)Y(o)Y(p)Y(q)Y(r)Y(s)Y(t)
Note that in line 2 the semicolon has moved to the front in order to
make each "int Z" of line 3 end with a semicolon as to not cause a
syntax error. (We can't use this idea twice because it would lead to
"int Z int Z" somewhere on line 5 :-) This generates exactly 847000
warnings. Interesting how I always arrive at a multiple of 1000.
Can we reach the one million warnings sonic barrier?
Regards,
Jens
--
Jens Schweikhardt http://www.schweikhardt.net/
SIGSIG -- signature too long (core dumped)
Cool! Note that with gcc you can always sprinkle a few semicolons at
file scope for extra warnings. If you use this "feature" to fill the
lines less than 80 chars, e.g (obeying the 80 chars rule) with
#define Z a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,I
#define _(x)x##_(Z){int _=(Z=(Z=(Z=(Z=(Z=(Z=(Z=(Z=(Z=(Z=(Z=(Z=(Z)))))))))))));};
#define X(x)_(x##A)_(x##B)_(x##C)_(x##D)_(x##E)_(x##F)_(x##G)_(x##H)_(x##I);;;;;
#define Y(x)X(x##A)X(x##B)X(x##C)X(x##D)X(x##E)X(x##F)X(x##G)X(x##H)X(x##I);;;;;
Y(a)Y(b)Y(c)Y(d)Y(e)Y(f)Y(g)Y(h)Y(i)Y(j)Y(k)Y(l)Y(m)Y(n)Y(o)Y(p)Y(q)Y(r)Y(s)Y(t)
we have
$ gcc -std=c89 -pedantic -Wall -W -Wtraditional -Wlarger-than-2 \
-Wstrict-prototypes -c warns.c 2>&1|grep warning:|wc -l
841780
$ gcc -std=c89 -pedantic -Wall -W -Wtraditional -Wlarger-than-2 \
-Wstrict-prototypes -c warns.c 2>&1|grep error:
$ gcc -v
Using built-in specs.
Configured with: FreeBSD/i386 system compiler
Thread model: posix
gcc version 3.4.4 [FreeBSD] 20050518
And all the 841780 warnings refer to the same line... A sharp look at the
naive ;-padding makes us realize there's more opportunity for warnings, e.g.
#define Z a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,I
#define _(x);x##_(Z){int _=(Z=(Z=(Z=(Z=(Z=(Z=(Z=(Z=(Z=(Z=(Z=(Z=(Z)))))))))))));}
#define X(x)_(x##A)_(x##B)_(x##C)_(x##D)_(x##E)_(x##F)_(x##G)_(x##H)_(x##I)int Z
#define Y(x)X(x##A)X(x##B)X(x##C)X(x##D)X(x##E)X(x##F)X(x##G)X(x##H)X(x##I);;;;;
Y(a)Y(b)Y(c)Y(d)Y(e)Y(f)Y(g)Y(h)Y(i)Y(j)Y(k)Y(l)Y(m)Y(n)Y(o)Y(p)Y(q)Y(r)Y(s)Y(t)
Note that in line 2 the semicolon has moved to the front in order to
make each "int Z" of line 3 end with a semicolon as to not cause a
syntax error. (We can't use this idea twice because it would lead to
"int Z int Z" somewhere on line 5 :-) This generates exactly 847000
warnings. Interesting how I always arrive at a multiple of 1000.
Can we reach the one million warnings sonic barrier?
Regards,
Jens
--
Jens Schweikhardt http://www.schweikhardt.net/
SIGSIG -- signature too long (core dumped)
Strange that I never saw my posts. Same author (Ardaen), same everything else, this one
generates 14,662,063 warnings.
#define Z a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,I
#define _(x)(Z=(Z=(Z=(Z=(Z=(Z=(Z=(Z=(Z=(Z=(Z=(Z=(Z=(Z=(Z=(Z=(x)))))))))))))))))
#define Y _=_(_(_(_(_(_(_(_(_(_(_(_(_(_(_(_(_(_(_(_(_(_(z))))))))))))))))))))))
#define X Y;Y;Y;Y;Y;Y;Y;Y;Y;Y;Y;Y;Y;Y;Y;Y;Y;Y;Y;Y;Y;Y;Y;Y;Y;Y;Y;Y;Y;Y;Y;Y;Y;Y;Y;
J(Z){int X;X;X;X;X;X;X;X;X;X;X;X;X;X;X;X;X;X;X;X;X;X;X;X;X;X;X;X;X;X;X;X;X;X;X;}
--
#include <standard.disclaimer>
_
Kevin D Quitt USA 91387-4454 96.37% of all statistics are made up
> On Thu, 03 Nov 2005 11:51:56 -0000, "E. Rosten" <lo...@my.sig> wrote:
>>On Sat, 29 Oct 2005 01:29:11 +0000, WillerZ wrote:
>>> E. Rosten wrote:
>>>> #define R(A) A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A
>>>> #define S(A) R(R(R(R(R(R(R(R(R(R(R(R(R(R(R(R(R(R(R(R(R(R(A))))))))))))))))))))))
>>>> #define T(A) S(S(S(S(S(S(S(S(S(S(S(S(S(S(S(S(S(S(S(S(S(S(A))))))))))))))))))))))
>>>> #define U(A) T(T(T(T(T(T(T(T(T(T(T(T(T(T(T(T(T(T(T(T(T(T(A))))))))))))))))))))))
>>>> float main(){int a=0,*b;S(b=a);S(b=a);S(b=a);S(b=a);S(b=a);S(b=a);S(b=a);S(b=a)}
>>
>>The last line is meant to reat U(b=a), etc, not S(b=a), otherwise it gives
>>a measly 10^38 errors.
>
> Might I ask on what system you are compiling this? I get nothing but core dumps.
A rather theortical machine, I'm afraid. All compilers I can find will
attempt to expand the entire macro and run out of memory rather quickly.
Also, 10^16000 bytes takes quite a long to be generated...
-Ed
--
(You can't go wrong with psycho-rats.) (er258)(@)(eng.cam)(.ac.uk)
/d{def}def/f{/Times findfont s scalefont setfont}d/s{10}d/r{roll}d f 5/m
{moveto}d -1 r 230 350 m 0 1 179{1 index show 88 rotate 4 mul 0 rmoveto}
for /s 15 d f pop 240 420 m 0 1 3 { 4 2 1 r sub -1 r show } for showpage
And that macro expansion has slightly exceeded the maximum
guaranteed compilable line length, which is somewhere in the 256 to
1024 range, depending on the appropriate C standard and my memory.
--
Read about the Sony stealthware that is a security leak, phones
home, and is generally illegal in most parts of the world. Also
the apparent connivance of the various security software firms.
http://www.schneier.com/blog/archives/2005/11/sonys_drm_rootk.html