tinycc-devel
[Top][All Lists]
Advanced

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

[Tinycc-devel] compare quoted strings


From: Henry Kroll
Subject: [Tinycc-devel] compare quoted strings
Date: Mon, 08 Nov 2010 03:35:44 -0800

This little snippet prints "true" if compiled with gcc and "not true" if
compiled with tcc.

int main (void){
    printf ("%sok\n","a"=="a"?"":"not ");
    return 0;
}

Note that "a"=="a" is not what it looks like. We are comparing the
address of the pointer "a" with itself. If the book I just looked at
(Banahan, et al., 1991) interprets the standard correctly, a quoted
string serves as a pointer to the first element, thus "a"=="a" should
return true.

Ref

Banahan, Mike, Brady, Declan and Doran, Mark. (1991). The C Book —
Character handling. Chapter 5.4. Retrieved November 8, 2010, from
http://publications.gbdirect.co.uk/c_book/chapter5/character_handling.html





reply via email to

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