Comments (2)
How do I reproduce this bug?
The simc code:
MAIN
print( "Hello World\n" )
var a = 13
var *ptr = &a
print( "Var 'a' is: \n" )
print( a )
print( "\n" )
print( "Pointer to 'a' is: \n" )
print( ptr )
print( "\n" )
print( "Value of pointer to 'a' is: \n" )
print( *ptr )
print( "\n" )
END_MAIN
We get this C code:
#include <stdio.h>
int main() {
printf("Hello World\n");
int a = 13;
float *ptr = & a;
printf("Var 'a' is: \n");
printf("%d", a);
printf("%c", '\n');
printf("Pointer to 'a' is: \n");
printf("%d", ptr);
printf("%c", '\n');
printf("Value of pointer to 'a' is: \n");
printf("%d", * ptr);
printf("%c", '\n');
return 0;
}
This code seems okay to me.
from sim-c.
Actually, on a side note, Sim-C is dynamically typed, so this should apply to pointers as well, right?
For this simc code:
MAIN
print( "Hello World\n" )
var a = 13
var *ptr = &a
print( "Value of pointer to 'a' is: \n" )
print( *ptr )
print( "\n" )
var b = 3.14
ptr = &b
print( "Pointer to 'b' is: \n" )
print( ptr )
print( "\n" )
print( "Value of pointer to 'b' is: \n" )
print( *ptr )
print( "\n" )
END_MAIN
We get this C code:
#include <stdio.h>
int main() {
printf("Hello World\n");
int a = 13;
float *ptr = & a;
printf("Value of pointer to 'a' is: \n");
printf("%d", * ptr);
printf("%c", '\n');
float b = 3.14;
ptr = & b;
printf("Pointer to 'b' is: \n");
printf("%f", ptr);
printf("%c", '\n');
printf("Value of pointer to 'b' is: \n");
printf("%f", * ptr);
printf("%c", '\n');
return 0;
}
This C code gives us the following error:
I think this simc code should produce a valid C code, but I'm not too sure.
Hope this made sense.
from sim-c.
Related Issues (20)
- [BUG REPORT] Incorrect Usage of Check Braces Flag HOT 2
- [BUG REPORT] Switch Case Is Not Working
- [BUG REPORT] array declaration gives error HOT 4
- [FEATURE] Generalize prec_to_type and type_to_prec dictionary
- [BUG REPORT] Error when function calls and constants are passed in array initializer list HOT 2
- [FEATURE] Redundant code in array_initializer (array_parser.py) HOT 4
- [FEATURE] Break var_statement function into further sub functions HOT 2
- [BUG REPORT] Incorrect error message when function is not defined HOT 4
- [BUG REPORT] stdio.h gets included for array/pointer declaration + assignment HOT 2
- [BUG REPORT] Cloned repo gets deleted on running tests HOT 1
- [FEATURE REPORT] Improvement of arrays: Differentiate array from variables to avoid bugs and check out for ranges when indexing
- [BUG REPORT] Power function not working when used inside parenthesis. HOT 3
- [BUG REPORT] Array initializer must detect too many commas
- [BUG REPORT] Pointer to pointer not working
- [BUG] Predict type in print HOT 1
- [FEATURE] Pretty print symbol table HOT 2
- [BUG] Function redefinition does not throw error HOT 3
- [BUG] Return type and dtype of parameters in a function is incorrect
- README.md enhancement
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sim-c.