tinycc-devel
[Top][All Lists]
Advanced

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

Re: [Tinycc-devel] __LINE__ and #line undelying type


From: Vincent Lefevre
Subject: Re: [Tinycc-devel] __LINE__ and #line undelying type
Date: Fri, 16 Apr 2021 10:15:47 +0200
User-agent: Mutt/2.0.6+148 (869c6cc4) vl-132933 (2021-04-10)

On 2021-04-16 07:11:27 +0200, Christian Jullien wrote:
> Even more strange, __LINE__ type changes as it overflows on clang, and gcc:
> 
> int
> main() {
> #line 2147483647
>   printf("__LINE__: %s\n", TYPEOF(__LINE__));
> #line 3000000000
>   printf("__LINE__: %s\n", TYPEOF(__LINE__));
> }
> 
> jullien@sims4:~ $ gcc -std=c11 foo.c -o foo && ./foo
> __LINE__: int
> __LINE__: long long

I think that this is expected. The standard just says that it is an
integer constant, not that it has a fixed type (which could break
many applications, as the largest type would have to be chosen even
for small line numbers). In practice, it just probably gives a
sequence of decimal digits (without a suffix), and the type is
deduced as usual for integer constants.

-- 
Vincent Lefèvre <vincent@vinc17.net> - Web: <https://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]