Go to Post Don't let the teams here be so much of an intimidation to you, but instead, an inspiration. They all had to start from the beginning, too. - Amanda Morrison [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Spotlight this post!  
Unread 17-02-2005, 23:20
Unsung FIRST Hero
Matt Leese Matt Leese is offline
Been-In-FIRST-Too-Long
FRC #1438 (The Aztechs)
Team Role: Engineer
 
Join Date: May 2001
Rookie Year: 1998
Location: Long Beach, CA
Posts: 937
Matt Leese has a reputation beyond reputeMatt Leese has a reputation beyond reputeMatt Leese has a reputation beyond reputeMatt Leese has a reputation beyond reputeMatt Leese has a reputation beyond reputeMatt Leese has a reputation beyond reputeMatt Leese has a reputation beyond reputeMatt Leese has a reputation beyond reputeMatt Leese has a reputation beyond reputeMatt Leese has a reputation beyond reputeMatt Leese has a reputation beyond repute
Send a message via AIM to Matt Leese
Nasty Compiler Bug

So the past couple weeks we've been working on our autonomous code on a test robot. Over this time we've been having problems and wracking our brains about outputs that just don't seem to make sense. I managed to track down at least one of the problems today and it appears to be a compiler bug. This is not a request for help but just trying to inform everyone else of the issue.

If you use the following statement:
Code:
long coeff_1 = 90/2*40;
coeff_1 will equal 8. Now this is obviously not the correct value (it should be 1800). For some reason, the compiler appears to do math in initalization statements (for long's at least) in a 8-bit space (1800 = 8 in an 8-bit space).

If you use this code:
Code:
long coeff_1 = 1800;
it will work correctly.

The long and the short of it is to always do any math out before putting it in the source code. While it's more work for you, it results in correctly generated code.

I'm not sure where to report this bug to Microchip so if anyone knows, please tell me.

Matt
 


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
IMPORTANT regarding the new C Compiler dlavery General Forum 12 14-01-2005 05:05
Makefile and stripped down compiler Venkatesh Programming 0 09-01-2005 18:55
multiple definition error in MCC/Linker (possible bug?) wun Programming 5 01-04-2004 17:49
printf bug - beware! WizardOfAz Programming 8 10-03-2004 09:50
C compiler for 2004 Tim Skloss Technical Discussion 11 05-11-2003 22:02


All times are GMT -5. The time now is 19:24.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi