Welcome, Guest. Please login or register.

Author Topic: StormC 64-bit arithmetic bug?  (Read 1003 times)

Description:

0 Members and 1 Guest are viewing this topic.

Offline MinuousTopic starter

StormC 64-bit arithmetic bug?
« on: September 17, 2004, 01:13:00 AM »
I seem to have found a bug in StormC? Try the following in "StormC 3" mode:

void main(void)
{   long long number;

    number = 10;
    number *= 2;
    printf("%Ld!\n", number);
}

The answer should be 20 but is not...!

On a related subject, does anyone have documentation for the undocumented AG2Index and GenDictionaries tools supplied with StormC 4?
 

Offline Cymric

  • Hero Member
  • *****
  • Join Date: Nov 2002
  • Posts: 1031
    • Show only replies by Cymric
Re: StormC 64-bit arithmetic bug?
« Reply #1 on: September 17, 2004, 09:15:03 AM »
Not sure whether this answer is of use, but I'll write it anyway. (I like to see myself write :-D.) According to the manpages of sprintf() on my Linux box, the 'L' modifier is only used in conjunction with long double. If you want to use the correct modifier for ints, one uses 'll' (ell-ell). And forgive me if I'm wrong here (I never use long longs), but shouldn't the declaration read 'long long int number'? Or does StormC understand that it is an int without explicitly writing it down?
Some people say that cats are sneaky, evil and cruel. True, and they have many other fine qualities as well.
 

Offline Karlos

  • Sockologist
  • Global Moderator
  • Hero Member
  • *****
  • Join Date: Nov 2002
  • Posts: 16867
  • Country: gb
  • Thanked: 4 times
    • Show only replies by Karlos
Re: StormC 64-bit arithmetic bug?
« Reply #2 on: September 17, 2004, 04:03:03 PM »
StormC 3 has a multitude of bugs and quirks, especially in C++ mode.

If you dump the number as a pair of unsigned longs (use a union of an array of 2 unsigned longs and 1 unsigned long long), you will see the arithmetic is correct, but in fact the formatted output is at fault.

Add this to improperly constructed arrays of polymoprphic objects, broken function template instansiation, ability to take the address of a nonstatic member function (without an object), non threadsafe exception handling... the list goes on :-/
int p; // A
 

Offline MinuousTopic starter

Re: StormC 64-bit arithmetic bug?
« Reply #3 on: September 25, 2004, 01:58:52 PM »
I'm actually using StormC 4.0, but with the StormC 3 compiler engine. In ANSI C mode, not C++, by the way.

And %Ld is correct for 64-bit signed decimals.
 

Offline Karlos

  • Sockologist
  • Global Moderator
  • Hero Member
  • *****
  • Join Date: Nov 2002
  • Posts: 16867
  • Country: gb
  • Thanked: 4 times
    • Show only replies by Karlos
Re: StormC 64-bit arithmetic bug?
« Reply #4 on: September 25, 2004, 02:13:43 PM »
I wasn't implying that you were using C++, just that overall the SC3 compiler model is seiously bug ridden.
int p; // A
 

Offline PiR

  • Full Member
  • ***
  • Join Date: Apr 2003
  • Posts: 148
    • Show only replies by PiR
Re: StormC 64-bit arithmetic bug?
« Reply #5 on: September 27, 2004, 05:33:13 PM »
Quote
ability to take the address of a nonstatic member function (without an object)


Well, without arguing that StormC is overloaded with bugs, which is very unfortunate, as it has really seriusly designed IDE and a lot of effort was obiously put in production of it, I doubt if this one is really a bug.

The method if really a function with the first argument 'hidden', which name is hardcoded to 'this'. For simple storing of address of that function no existing object is needed.

To be honest, if such constructs were forbidden by the compiler, I belive THAT would be a bug. The other thing is if such constructs are usefull for anything, while the same thing can be probabily designed with virtual methods.

My 2 grosz'es (1/100 of the national currency in Poland)