[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: spurious C warnings..



On Wed, Feb 22, 2006 at 03:28:08PM +0000, Digby Tarvin wrote:
>The is probably not specific to Debian, but the system I encountered it
>on is Debian 3.1 (Sarge/Stable) and perhaps someone here can explain
>it...
>
>If I compile the program:
>	main()
>	{
>	        long long foo = 077777777777777777777;
>	
>	
>	        printf("sizeof foo is %d %llx\n", sizeof foo, foo);
>	}
>the compiler produces the warning:
>	$ cc test.c
>	test.c: In function `main':
>	test.c:3: warning: integer constant is too large for "long" type
>
>which would be entirely reasonable had I tried to use the constant
>with a long type - but in this case I am not, so it seems completely
>spurious.... (why not warn me about it being too long for int and
>char also??)
>
>If I run the program, it is evident that the correct code it generated:
>	./a.out
>	sizeof foo is 8 fffffffffffffff
>
>I am guessing that long long literals are a language extension, but don't
>have any reference here with which to check that...
>
>Anyone know the reason for the warning, and if there is an option that
>suppresses it?
>
>I tried it on gcc 2.95.3 on my old (SuSE) system and it does not happen,
>but on Debians 3.3.5 it does.

See http://sources.redhat.com/ml/crossgcc/2004-02/msg00036.html

/M

-- 
Magnus Therning                    (OpenPGP: 0xAB4DFBA4)
magnus@therning.org
http://therning.org/magnus

Software is not manufactured, it is something you write and publish.
Keep Europe free from software patents, we do not want censorship
by patent law on written works.

Some operating systems are called 'user friendly', Linux however is
'expert friendly'.

Attachment: pgpVm0gjmHYsL.pgp
Description: PGP signature


Reply to: