Re: problem with C and Gcc 2.95.3

From: Jeroen Latour (qat_private)
Date: Sat May 26 2001 - 18:12:42 PDT

  • Next message: Riley Hassell: "Re: problem with C and Gcc 2.95.3"

    At 22:47 26-5-2001, you wrote:
    >Which is why I let the message through.  Any reason why a %d stepping off
    >the end of a buffer would end up printing out the environment like that?
    >Or is it certain that the source that was mailed in doesn't match the
    >output?
    
    
    # cat > problem.c
    #include <stdio.h>
    main () {
    char buff[10];
    int i;
             for (i=0;i<10;i++){
                     buff[i]='.';
             }
             for (i=0;1<10;i++){
                     printf("%d",buff[i]);
             }
    }
    # gcc -o problem problem.c
    # ./problem
    46464646464646464646-1-65104-5-1-65-21-1263641000-100-5-1-65-92-5-1-65-128-124480000104-5-1-65-67-126364-10490164100016-12548-100-5-1-6548-126364401031864000049-12548-16-125481000-100-5-1-65-104-12648-128-12448-64-63064-116-5-1-65-1249616411331064-92-5-1-651000-116-4-1-650000-106-4-1-65-96-4-1-65-81-4-1-65-57-4-1-65-44-4-1-65-33-4-1-65-23-4-1-65-18-2-1-659-1-1-6535-1-1-6542-1-1-6555-1-1-6563-1-1-6579-1-1-6593-1-1-65110-1-1-65121-1-1-65-124-1-1-65-45-1-1-65-26-1-1-650000300052-128484000320005000600070000006480000000900016-1254811000000012000000013000000014000000016000-651006000016001700010000015000-121-4-1-6500000000000000000000000000000001055356540464711211411198108101109080876861471141111111160727983847865776961109111110116121076839579808473797883614545991111081111146197117116111080834961921045892119923632086738385657661106111101085836982611141111111160768395677976798283611101116148485810210561484858100105614849595152581081106148495951545811210561524859515158115111614849595153581
    0 
    01116148495951535898100615248595151594849589910061524859515159484958111114615248595149594849581011206148495951505842461169711461484959514958424611610312261484959514958424697114106614849595149584246116971226148495951495842461081221046148495951495842461221051126148495951495842461226148495951495842469061484959514958424610312261484959514958424698122506148495951495842461001019861484959514958424611411210961484959514958424610697114614849595149584246106112103614849595153584246106112101103614849595153584246112110103614849595153584246103105102614849595153584246981091126148495951535842461129810961484959515358424611210310961484959515358424611211210961484959515358424611610397614849595153584246120981096148495951535842461201121096148495951535842461161051026148495951535842461161051021026148495951535842461091121036148495951535842461091121011036148495951535842469711810561484959515358424610210810561484959515358424610310861484959515358424610010861484959515358424612099102614849595153584246120119100614
    8 
    49595153580776567728489806961105515654451129945108105110Segmentation fault
    # gcc -v
    Reading specs from /usr/lib/gcc-lib/i386-linux/2.95.4/specs
    gcc version 2.95.4 20010506 (Debian prerelease)
    
    Unless the problem was fixed in 2.95.4 (which doesn't appear to be the 
    case, according to changelog), I think the source indeed does differ.
    Replacing %d with %c does indeed produce similiar output as in the original 
    mail.
    
    Jeroen Latour
    



    This archive was generated by hypermail 2b30 : Sat May 26 2001 - 22:10:57 PDT