Nios® V/II Embedded Design Suite (EDS)
Support for Embedded Development Tools, Processors (SoCs and Nios® V/II processor), Embedded Development Suites (EDSs), Boot and Configuration, Operating Systems, C and C++

Problem with gcc4 toolchain

Altera_Forum
Honored Contributor II
1,025 Views

Hello, 

 

i have written following code to demonstrate the issue: 

# include <stdio.h> 

 

int main(void) 

unsigned long long int long_val = 0xaaaaaaaaaaaaaaaaLLU; 

unsigned long vala = 0xbbbbbbbbL; 

unsigned long valb = 0xccccccccL; 

 

printf("%lx | %lx | %llx\r\n", vala, valb, long_val); 

printf("%llx | %lx | %lx\r\n", long_val, vala, valb); 

 

return 0; 

 

 

using the GCC4 toolchain the output is: 

bbbbbbbb | cccccccc | aaaaaaaa 

aaaaaaaa | aaaaaaaa | bbbbbbbb 

 

using the GCC3 toolchain the output is: 

bbbbbbbb | cccccccc | aaaaaaaaaaaaaaaa 

aaaaaaaaaaaaaaaa | aaaaaaaa | bbbbbbbb 

 

Using sprintf or snprintf shows the same issue. Seems that something is wrong with 64bit Integer handling in these functions. 

I use the NIOS SBT 10.0 on Windows 7. 

 

Is is a known bug?
0 Kudos
3 Replies
Altera_Forum
Honored Contributor II
265 Views

We are watching this post closely so if you run into similar issues with the compiler upgrade that occurred in 10.0 please post them here and/or file a service request at this location and mention my name "Jarrod" in the description so that I can keep an eye on the issue: https://www.altera.com/myaltera/mal-index.jsp while referencing this post. 

 

If you file a service request please attach your system and software if possible to help us re-create the issue (this always helps any time you file a service request). A minimal set of files is always welcome so if you can re-produce this issue with a minimal set of components in your system that always helps us and if you have any additional information please provide it via notes in the service request. 

 

Thank-you, 

Jarrod - Embedded Applications Altera
0 Kudos
Altera_Forum
Honored Contributor II
265 Views

Looks like a bug in the varargs processing, probably the va_arg() bit. 

I can't remember what the nios2 ABI says about varargs functions, and whether all the arguments get stacked, or whether they still get passed in registers. 

 

If it only affects printf(), it might just be that the printf code isn't detecting the double 'l'. 

 

Are the gcc sources for gcc 4 on the altera ftp site yet?
0 Kudos
Altera_Forum
Honored Contributor II
265 Views

We are coming to the same conclusion on our side. We are still trying to figure out the extent of the issue. 

 

I doubt the gcc sources are up yet.
0 Kudos
Reply