Windows Vista Problems with access() and printf("%n", ...)

Roland Puntaier <Roland.Puntaier-5O2GiQo/Ci2aMPzRcYMCawC/[email protected]> Tue, 23 Jan 2007 19:51:19 +0100
Newsgroups gmane.comp.gnu.mingw.patches
Message-ID <OF8BF71DBC.F017E31A-ONC125726C.0064B130-C125726C.00679400@br-automation.com>
Hello,

I tried to file this as bug in the bug tracker, but I cannot log onto 
sourceforge. I registered, got a user ID and password, but it says 
something like "wrong user id or password".

So I mail the problems I encountered here:

I am trying to compile and use GCC 4.1.0 on Windows Vista. 

access() does not work on Vista
-----------------------------------------------
When using a version compiled on XP, one has to add the path to CC1 to the 
PATH environment variable.
This is not a good solution.
Debugging into gcc I found that in gcc.c in the function process_command() 
the relative path returned by make_relative_prefix is OK.
But then the function access (defined in io.h) fails.
I made a separate test program:

    #include <stdio.h>
    int main()
    {
      if (0==access("c:/mygcc/libexec/gcc/i386-elf/4.1.0/cc1.exe",1))
        printf("can access");
      else
        printf("cannot access");
      return 0;
    }

This returns "cannot access" under Vista, but "can access" under XP. The 
path is OK and the same on both PCs.
When debugging there is also a "warning: Invalid parameter passed to C 
runtime function" under Vista.

printf with %n fails on Vista
--------------------------------------
When trying to compile GCC I found that min-insn-modes.c and insn-modes.c 
get huge and finally lead to a "disk full".
The reason was in in the genmodes.c,  emit_mode_class(), tagged_printf 
macro. It calls printf with %n.
The behavior was that for some calls it only didn't return the value for 
%n, but then it suddenly started printing blanks until disk fill.

The following test program works on XP, but does not on Vista, i.e. count_ 
is not updated.

    #include <stdio.h>
    int main()
    {
      int count_=20;
      int i;
#define SC 2
      char* astr[SC]={"my","test"};

      for (i=0;i<SC;++i)
      {
        printf("%s,%n",astr[i],&count_);
        printf("\ncount was %i\n",count_);
      }
      return 0;
    }


cheers, Roland
roland.puntaier-5O2GiQo/Ci2aMPzRcYMCawC/[email protected]

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV