473,786 Members | 2,744 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Safe subset of C?

I am looking for other people's attempts to create safe subset of C and
enforce it with scripts. Does anybody know about anything like this?

By "safe", I mean the following:
* Strongly typed memory. No way to reinterpret it as bunch of bytes
* Recovery from invalid and NULL pointers other than crash
* Possibility to isolate piece of code by not giving it key pointers

Library used to support such safe subset must not introduce its own flaws.
For example, it is not a good idea to use int proxies for pointers like
Unix API does, because this allows pointer guessing and consequently
prevents isolation.

Nov 13 '05
36 3893
Christian Bau <ch***********@ cbau.freeserve. co.uk> wrote:
In article <pa************ *************** *@lightspeed.bc .ca>,
Kelsey Bjarnason <ke*****@lights peed.bc.ca> wrote:
On Mon, 24 Nov 2003 19:06:16 +0100, Robert Vazan wrote:
> On Sun, 23 Nov 2003 19:17:27 -0500, Sheldon Simms wrote:
>
>> I guess you figure that all those "smart programmers" are incapable of
>> using any other language.
>
> I didn't want to offend you. I am also capable of using other languages,
> but I have got very sensitive to quality of tools and I am consequently
> very sceptical about any new language.
>
>> I can't speak for anyone else, but I wouldn't be
>> interested in working in crippled C.
>
> So you compile with warnings turned off?


Having warnings enabled doesn't cripple C; it just lets you know when
you've done something that probably isn't actually C at all. :)

If it isn't C at all you would get an error. If you get a warning, it's
most likely perfectly legal C that in some non-obvious way does
something entirely different from what you intended.


AFAIK "diagnostic s" need only be output from the compiler,
not specifically as "errors" or "warnings".

Alex
Nov 13 '05 #31
On Tue, 25 Nov 2003 18:14:22 +0100, Robert Vazan wrote:
On Mon, 24 Nov 2003 15:29:41 -0500, Sheldon Simms wrote:
Warnings don't prevent me from doing anything, and lots of things


You can get warning that not all members of enum are enumerated in switch
statement. You can get warning about missing return statement even if you
know that end of function is unreachable.


Indeed. How is C crippled by such warnings?
that you want to disallow, such as treating any object as an array of
bytes, can be done perfectly safely and portably.


The only thing that you can do portably is copying those bytes to new
location. Reflection and metadata can do much more and they are type-safe.


What does that have to do with C?

Nov 13 '05 #32
[snips]

On Tue, 25 Nov 2003 07:58:14 +0000, Christian Bau wrote:
Having warnings enabled doesn't cripple C; it just lets you know when
you've done something that probably isn't actually C at all. :)


If it isn't C at all you would get an error.


Really? Hmm.

[kelseyb@baldur]$ gcc test.c
test.c: In function `main':
test.c:3: warning: `return' with a value, in function returning void
test.c:2: warning: return type of `main' is not `int'

The code:

void main()
{
return 0;
}
Seems I get a warning, not an error with warnings enabled. So, you're
suggesting that void main() is, in fact, C? As I recall, the standards
explicitly state that main returns int, not void, not double, not pointer
to char, but int, and anything else ain't C.
Nov 13 '05 #33
On 2003-11-25, Robert Vazan <ro*********@pr ivateweb.sk> wrote:
On Tue, 25 Nov 2003 01:01:10 -0600, James Hu wrote:
There are already tools that do this. A web search for memory
debugging tools will provide many hits.


They aren't suitable for release code. And even in debug code, they crash
the program. It's just that they crash it near to point of error.


Not all of them behave as you describe. I am offering you the
suggestion to encourage you to not re-invent the wheel.

-- James
Nov 13 '05 #34
Alex <al*******@hotm ail.com> scribbled the following:
Christian Bau <ch***********@ cbau.freeserve. co.uk> wrote:
In article <pa************ *************** *@lightspeed.bc .ca>,
Kelsey Bjarnason <ke*****@lights peed.bc.ca> wrote:
Having warnings enabled doesn't cripple C; it just lets you know when
you've done something that probably isn't actually C at all. :)
If it isn't C at all you would get an error. If you get a warning, it's
most likely perfectly legal C that in some non-obvious way does
something entirely different from what you intended.
AFAIK "diagnostic s" need only be output from the compiler,
not specifically as "errors" or "warnings".


So does this:

"ISO says I have to issue a diagnostic here. So to keep them happy I'll
do so."

qualify as a mandatory diagnostic for a case for which the ISO C
standard mandates one?

--
/-- Joona Palaste (pa*****@cc.hel sinki.fi) ------------- Finland --------\
\-- http://www.helsinki.fi/~palaste --------------------- rules! --------/
"To err is human. To really louse things up takes a computer."
- Anon
Nov 14 '05 #35
In article <br**********@o ravannahka.hels inki.fi>,
Joona I Palaste <pa*****@cc.hel sinki.fi> wrote:
Alex <al*******@hotm ail.com> scribbled the following:
Christian Bau <ch***********@ cbau.freeserve. co.uk> wrote:
If it isn't C at all you would get an error. If you get a warning, it's
most likely perfectly legal C that in some non-obvious way does
something entirely different from what you intended.

AFAIK "diagnostic s" need only be output from the compiler,
not specifically as "errors" or "warnings".


So does this:

"ISO says I have to issue a diagnostic here. So to keep them happy I'll
do so."

qualify as a mandatory diagnostic for a case for which the ISO C
standard mandates one?


Wouldn't that depend on whether it's documented by the compiler as
a diagnostic?

Perhaps a better wording would be "...So to keep them happy I'm doing
so.". That way it's clear from the message that it is in fact the
required diagnostic.
dave
(In a pedantic mood today, it seems. Not that that's a Bad Thing.)

--
Dave Vandervies dj******@csclub .uwaterloo.ca
[W]hen I am among non-physician Ph.D.s who go by "Doctor" then I like
to be called "Bachelor Petrofsky" in honor of my B.S..
--Al Petrofsky in comp.lang.schem e
Nov 14 '05 #36
Joona I Palaste <pa*****@cc.hel sinki.fi> wrote:
Alex <al*******@hotm ail.com> scribbled the following:
Christian Bau <ch***********@ cbau.freeserve. co.uk> wrote:
In article <pa************ *************** *@lightspeed.bc .ca>,
Kelsey Bjarnason <ke*****@lights peed.bc.ca> wrote:
Having warnings enabled doesn't cripple C; it just lets you know when
you've done something that probably isn't actually C at all. :) If it isn't C at all you would get an error. If you get a warning, it's
most likely perfectly legal C that in some non-obvious way does
something entirely different from what you intended.
AFAIK "diagnostic s" need only be output from the compiler,
not specifically as "errors" or "warnings".
So does this: "ISO says I have to issue a diagnostic here. So to keep them happy I'll
do so." qualify as a mandatory diagnostic for a case for which the ISO C
standard mandates one?


Sure. The extent of the diagnostic is not defined. It is a QoI
issue.

Alex
Nov 14 '05 #37

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

42
2603
by: Irmen de Jong | last post by:
Pickle and marshal are not safe. They can do harmful things if fed maliciously constructed data. That is a pity, because marshal is fast. I need a fast and safe (secure) marshaler. Is xdrlib the only option? I would expect that it is fast and safe because it (the xdr spec) has been around for so long. Or are there better options (perhaps 3rd party libraries)?
15
2197
by: les_ander | last post by:
Hi, I have many set objects some of which can contain same group of object while others can be subset of the other. Given a list of sets, I need to get a list of unique sets such that non of the set is an subset of another or contain exactly the same members. Tried to do the following: s1=set() s2=set() s3=set()
29
7487
by: Chris Dutrow | last post by:
I searched around on the net for a bit, couldn't find anything though. I would like to find some code for a function where I input A Range Of Integers For example: Function( 1, 100 ); And the function will return me an array holding a random subset of integers in that range of a size that I specify So the Function would Probabaly look something like this:
24
1819
by: Dan Bass | last post by:
I know that XslTransform's Transform is thread safe according to the MSDN, and that Load is not. I've therefore applied this simply Mutex to it and would just like to confirm this is okay. XslTransform xslt = null; Mutex mut = new Mutex(); public override string MapMessage ( string messageSource ) {
8
1328
by: Jon Paul Jones | last post by:
For some time now, I have been looking for a build system for ASP.NET that will merge the file based ease of deployment of classic ASP with the type saftey and prebuilt nature of ASP.NET with codebehind. The team that I work on manages several web sites and we have many different projects (not VS projects) going on in each site simultaneously. Each of these projects may have different deployment schedules. In a classis ASP world this was...
0
1056
by: Babar K. Zafar | last post by:
Hi guys! I know this subject has been beaten to death and I am not going to whine about lacking features for proper restricted execution in the Python runtime. It's the OS job, I get it. Anyways, I thought about using a restricted *subset* of the language for simple configuration scripts and storing data in a user-friendly way. I'm fully aware about the dangers of introducing "eval" into the picture so I took different route and...
72
4452
by: jacob navia | last post by:
We have discussed often the proposition from Microsoft for a safer C library. A rationale document is published here by one of the members of the design team at microsoft: http://msdn.microsoft.com/msdnmag/issues/05/05/SafeCandC/default.aspx jacob
1
4627
by: jecheney | last post by:
Hi, Im currently using the following code for reading/writing to a network socket. private StreamReader clientStreamReader; private StreamWriter clientStreamWriter; .... TcpClient tcpClient = new TcpClient(server_host_name, server_port);
9
2931
by: Szabolcs | last post by:
I am not familiar with the UTF-8 encoding, but I know that it encodes certain characters with up to four bytes. Is it safe to use UTF-8 encoded comments in C++ source files? For example, is there a remote possibility that some multi-byte character, when interpreted byte-by-byte, will contain */ and close the comment? Or is there something else that can go wrong?
0
9650
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10164
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10110
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9962
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7515
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6748
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5534
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3670
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2894
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.