free() multiple allocation error in C
=============== =============== ======
Hi!
I have written a program in C on PC with Windows 2000 in a Visual C
environment.
I have an error in freeing multiple allocation as follows:
1. I allocated an array of pointer.
2. I Read line by line from a text file.
3. I allocated memory for the read line.
4. I wrote the pointer from malloc() to the array of pointers.
5. The problem is in the free() function. When I tried to free in a
loop the
allocated lines, the Visual C throw me with an exception.
6. I wanted to know why?. I tried also to free in the opposite order I
have
allocated them, but this also doesn't work.
7. Does anyone has an idea?
8. Please send answer to a.*****@solidgr oup.com .
9. Thanks in advance.
Ariel Ze'evi.
Parts of the code:
#include "stdafx.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define byte unsigned char
#define word unsigned short
typedef struct {
word FlashAddress, index;
} IndexAddress;
FILE *fp;
char **FileBuff;
IndexAddress *AddStruct;
word LinesNumber=0;
int main(int argc, char* argv[])
{
char FileName[]={"c:\\ariel\\f lash196\\modbus .hex"};
char line[MAX_LINE];
long BufSize=0;
word i,LineLen=0;
// Open for read (will fail if file "FileName" does not exist)
if( (fp = fopen( FileName, "r" )) == NULL )
printf( "The file %s was not opened\n",FileN ame );
else
printf( "The file '%s was opened\n",FileN ame );
// Finds Number of lines in the Hex File
while (!feof(fp))
{
fgets(line,MAX_ LINE,fp);
LinesNumber++;
}
printf("\nLines Number=%d\n",Li nesNumber);
// Allocate an array of pointers to number of lines
if((FileBuff = (char **)malloc(Lines Number * sizeof(char *)))==NULL)
{
printf("malloc error!\n");
return -1;
}
rewind(fp);
// Read line by line from file, allocate a memory to it and copy line
to allocation
for(i=0; i<LinesNumber; i++)
{
fgets(line,MAX_ LINE,fp);
if((FileBuff[i] = (char *)malloc(strlen (line) *
sizeof(char)))= =NULL)
{
printf("malloc error!\n");
return -1;
}
strcpy(FileBuff[i],line);
}
// Allocate an array of pointers to number of lines
AddStruct = (IndexAddress*) malloc(LinesNum ber *
sizeof(IndexAdd ress));
if(AddStruct ==NULL)
{
printf("malloc error!\n");
return -1;
}
// Prepare for sorting
for(i=0; i<LinesNumber; i++)
{
AddStruct[i].FlashAddress=A ddress(i);
AddStruct[i].index=i;
}
PrintAddIndex() ;
QuickSort(AddSt ruct,0,LinesNum ber);
PrintAddIndex() ;
for(i=0; i<LinesNumber; i++)
free(FileBuff[i]); <====== IN THIS POINT THE PROGRAM WAS
THROWN.
free(FileBuff);
/* Close fp */
if( fclose( fp ) )
printf( "The file %s was not closed\n",FileN ame );
return 0;
} 13 2477
Check if u are trying to free the memory which is freed before..
[snips]
On Thu, 27 Apr 2006 03:15:30 -0700, a.*****@solidgr oup.com wrote: #define byte unsigned char #define word unsigned short
Some reason for not using typedefs?
FILE *fp; char **FileBuff; IndexAddress *AddStruct; word LinesNumber=0;
int main(int argc, char* argv[]) { char FileName[]={"c:\\ariel\\f lash196\\modbus .hex"};
Ick. Lose the braces.
char line[MAX_LINE]; long BufSize=0; word i,LineLen=0;
// Open for read (will fail if file "FileName" does not exist) if( (fp = fopen( FileName, "r" )) == NULL ) printf( "The file %s was not opened\n",FileN ame ); else printf( "The file '%s was opened\n",FileN ame );
If it doesn't open, wouldn't it be more graceful to handle that
explicitly, say by exiting, or whatever?
// Finds Number of lines in the Hex File while (!feof(fp)) { fgets(line,MAX_ LINE,fp); LinesNumber++; }
Ugly, as it gets the eof test bass-ackwards. Basically, feof is only
going to be true _after_ fgets fails, reading past the last line.
printf("\nLines Number=%d\n",Li nesNumber);
// Allocate an array of pointers to number of lines if((FileBuff = (char **)malloc(Lines Number * sizeof(char *)))==NULL) {
Repeat after me: "We do *not* cast malloc." Repeat five or six hundred
times. If your compiler is complaining, then a) You're actually using
C++, b) You forget a header you need, or c) you're doing something wrong.
printf("malloc error!\n"); return -1;
No such critter as -1. It's 0, EXIT_SUCCESS or EXIT_FAILURE.
// Read line by line from file, allocate a memory to it and copy line to allocation for(i=0; i<LinesNumber; i++) { fgets(line,MAX_ LINE,fp); if((FileBuff[i] = (char *)malloc(strlen (line) * sizeof(char)))= =NULL)
Why are you using sizeof(char)? If you had to multiply 7*3, would you
write it as (7*1) * (3*1)? No? So why are you doing completely pointless
multiplication by 1? Hint: sizeof(char) is 1. Period. Hence it's
completely pointless in virtually every case you'll ever see it used.
That said, you're allocating one too few characters. For example, if your
line in the file is ABC\n, your "line" variable will contain "ABC\n\0".
That's 5 chars - but strlen only returns 4; it doesn't include the \0 at
the end. So you're short one byte.
strcpy(FileBuff[i],line);
And, of course, this right here may well puke and die as you try to
merrily write past the end of the allocated region.
for(i=0; i<LinesNumber; i++) free(FileBuff[i]); <====== IN THIS POINT THE PROGRAM WAS THROWN.
At a guess, since none of your strings are actually strings - lacking
the \0 - I'd suspect you're trashing the data that malloc/free use to
track what's been allocated.
It's also entirely possible that your sort routine is mucking things up;
if it's doing string-based comparisons on non-strings, bad things will
happen there, too. a.*****@solidgr oup.com wrote: free() multiple allocation error in C =============== =============== ======
Hi! I have written a program in C on PC with Windows 2000 in a Visual C environment. I have an error in freeing multiple allocation as follows: 1. I allocated an array of pointer. 2. I Read line by line from a text file. 3. I allocated memory for the read line. 4. I wrote the pointer from malloc() to the array of pointers. 5. The problem is in the free() function. When I tried to free in a loop the allocated lines, the Visual C throw me with an exception. 6. I wanted to know why?. I tried also to free in the opposite order I have allocated them, but this also doesn't work. 7. Does anyone has an idea? 8. Please send answer to a.*****@solidgr oup.com . 9. Thanks in advance. Ariel Ze'evi.
Parts of the code:
#include "stdafx.h" #include <stdio.h> #include <stdlib.h> #include <string.h>
#define byte unsigned char #define word unsigned short
typedef struct { word FlashAddress, index; } IndexAddress;
FILE *fp; char **FileBuff; IndexAddress *AddStruct; word LinesNumber=0;
int main(int argc, char* argv[]) { char FileName[]={"c:\\ariel\\f lash196\\modbus .hex"}; char line[MAX_LINE]; long BufSize=0; word i,LineLen=0;
// Open for read (will fail if file "FileName" does not exist) if( (fp = fopen( FileName, "r" )) == NULL ) printf( "The file %s was not opened\n",FileN ame ); else printf( "The file '%s was opened\n",FileN ame );
// Finds Number of lines in the Hex File while (!feof(fp)) { fgets(line,MAX_ LINE,fp); LinesNumber++; } printf("\nLines Number=%d\n",Li nesNumber);
// Allocate an array of pointers to number of lines if((FileBuff = (char **)malloc(Lines Number * sizeof(char *)))==NULL) { printf("malloc error!\n"); return -1; }
rewind(fp);
// Read line by line from file, allocate a memory to it and copy line to allocation for(i=0; i<LinesNumber; i++) { fgets(line,MAX_ LINE,fp); if((FileBuff[i] = (char *)malloc(strlen (line) * sizeof(char)))= =NULL) { printf("malloc error!\n"); return -1; } strcpy(FileBuff[i],line); }
// Allocate an array of pointers to number of lines AddStruct = (IndexAddress*) malloc(LinesNum ber * sizeof(IndexAdd ress)); if(AddStruct ==NULL) { printf("malloc error!\n"); return -1; }
// Prepare for sorting for(i=0; i<LinesNumber; i++) { AddStruct[i].FlashAddress=A ddress(i); AddStruct[i].index=i; } PrintAddIndex() ;
QuickSort(AddSt ruct,0,LinesNum ber); PrintAddIndex() ;
for(i=0; i<LinesNumber; i++) free(FileBuff[i]); <====== IN THIS POINT THE PROGRAM WAS THROWN. free(FileBuff);
/* Close fp */ if( fclose( fp ) ) printf( "The file %s was not closed\n",FileN ame );
return 0; }
1. I allocated an array of pointer 5. The problem is in the free() function. When I tried to free in a loop the allocated lines, the Visual C throw me with an exception.
Passing the base address of the pointer array should
free the entire memory you allocated in step 1 (I assume you
allocated one big chunk). As somebody posted before, you might
be trying to free the same memory twice.
Rgds.
Amogh
Kelsey Bjarnason wrote: [snips]
On Thu, 27 Apr 2006 03:15:30 -0700, a.*****@solidgr oup.com wrote:
#define byte unsigned char #define word unsigned short
Some reason for not using typedefs?
FILE *fp; char **FileBuff; IndexAddres s *AddStruct; word LinesNumber=0;
int main(int argc, char* argv[]) { char FileName[]={"c:\\ariel\\f lash196\\modbus .hex"};
Ick. Lose the braces.
char line[MAX_LINE]; long BufSize=0; word i,LineLen=0;
// Open for read (will fail if file "FileName" does not exist) if( (fp = fopen( FileName, "r" )) == NULL ) printf( "The file %s was not opened\n",FileN ame ); else printf( "The file '%s was opened\n",FileN ame );
If it doesn't open, wouldn't it be more graceful to handle that explicitly, say by exiting, or whatever?
// Finds Number of lines in the Hex File while (!feof(fp)) { fgets(line,MAX_ LINE,fp); LinesNumber++; }
Ugly, as it gets the eof test bass-ackwards. Basically, feof is only going to be true _after_ fgets fails, reading past the last line.
printf("\nLines Number=%d\n",Li nesNumber);
// Allocate an array of pointers to number of lines if((FileBuff = (char **)malloc(Lines Number * sizeof(char *)))==NULL) {
Repeat after me: "We do *not* cast malloc." Repeat five or six hundred times. If your compiler is complaining, then a) You're actually using C++, b) You forget a header you need, or c) you're doing something wrong.
printf("malloc error!\n"); return -1;
No such critter as -1. It's 0, EXIT_SUCCESS or EXIT_FAILURE.
// Read line by line from file, allocate a memory to it and copy line to allocation for(i=0; i<LinesNumber; i++) { fgets(line,MAX_ LINE,fp); if((FileBuff[i] = (char *)malloc(strlen (line) * sizeof(char)) )==NULL)
Why are you using sizeof(char)? If you had to multiply 7*3, would you write it as (7*1) * (3*1)? No? So why are you doing completely pointless multiplication by 1? Hint: sizeof(char) is 1. Period. Hence it's completely pointless in virtually every case you'll ever see it used.
That said, you're allocating one too few characters. For example, if your line in the file is ABC\n, your "line" variable will contain "ABC\n\0". That's 5 chars - but strlen only returns 4; it doesn't include the \0 at the end. So you're short one byte.
strcpy(FileBuff[i],line);
And, of course, this right here may well puke and die as you try to merrily write past the end of the allocated region.
for(i=0; i<LinesNumber; i++) free(FileBuff[i]); <====== IN THIS POINT THE PROGRAM WAS THROWN.
At a guess, since none of your strings are actually strings - lacking the \0 - I'd suspect you're trashing the data that malloc/free use to track what's been allocated.
It's also entirely possible that your sort routine is mucking things up; if it's doing string-based comparisons on non-strings, bad things will happen there, too.
Repeat after me: "We do *not* cast malloc." Repeat five or six hundred times. If your compiler is complaining, then a) You're actually using C++, b) You forget a header you need, or c) you're doing something >wrong.
Why shouldnt one cast malloc ? I use gcc 3.2, and it does crib if I dont
cast malloc. I might be missing your point somehow. Please enlighten.
Rgds.
Amogh
Amogh opined: Kelsey Bjarnason wrote: [snips]
>Repeat after me: "We do *not* cast malloc." Repeat five or six >hundred >times. If your compiler is complaining, then a) You're actually >using C++, b) You forget a header you need, or c) you're doing >something >wrong. Why shouldnt one cast malloc ? I use gcc 3.2, and it does crib if I dont cast malloc.
That'd be because you forgot to include <stdlib.h>.
I might be missing your point somehow. Please enlighten.
The point is to crib if you forget to include <stdlib.h>
All other points made above apply as well.
--
"It's God. No, not Richard Stallman, or Linus Torvalds, but God."
(By Matt Welsh)
<http://clc-wiki.net/wiki/Introduction_to _comp.lang.c> a.*****@solidgr oup.com wrote: free() multiple allocation error in C =============== =============== ======
Hi! I have written a program in C on PC with Windows 2000 in a Visual C environment. I have an error in freeing multiple allocation as follows: 1. I allocated an array of pointer. 2. I Read line by line from a text file. 3. I allocated memory for the read line. 4. I wrote the pointer from malloc() to the array of pointers. 5. The problem is in the free() function. When I tried to free in a loop the allocated lines, the Visual C throw me with an exception. 6. I wanted to know why?. I tried also to free in the opposite order I have allocated them, but this also doesn't work. 7. Does anyone has an idea? 8. Please send answer to a.*****@solidgr oup.com . 9. Thanks in advance. Ariel Ze'evi.
Parts of the code:
#include "stdafx.h" #include <stdio.h> #include <stdlib.h> #include <string.h>
#define byte unsigned char #define word unsigned short
typedef struct { word FlashAddress, index; } IndexAddress;
FILE *fp; char **FileBuff; IndexAddress *AddStruct; word LinesNumber=0;
int main(int argc, char* argv[]) { char FileName[]={"c:\\ariel\\f lash196\\modbus .hex"}; char line[MAX_LINE]; long BufSize=0; word i,LineLen=0;
// Open for read (will fail if file "FileName" does not exist) if( (fp = fopen( FileName, "r" )) == NULL ) printf( "The file %s was not opened\n",FileN ame ); else printf( "The file '%s was opened\n",FileN ame );
// Finds Number of lines in the Hex File while (!feof(fp)) { fgets(line,MAX_ LINE,fp); LinesNumber++; } printf("\nLines Number=%d\n",Li nesNumber);
// Allocate an array of pointers to number of lines if((FileBuff = (char **)malloc(Lines Number * sizeof(char *)))==NULL) { printf("malloc error!\n"); return -1; }
rewind(fp);
// Read line by line from file, allocate a memory to it and copy line to allocation for(i=0; i<LinesNumber; i++) { fgets(line,MAX_ LINE,fp); if((FileBuff[i] = (char *)malloc(strlen (line) * sizeof(char)))= =NULL) { printf("malloc error!\n"); return -1; } strcpy(FileBuff[i],line); }
// Allocate an array of pointers to number of lines AddStruct = (IndexAddress*) malloc(LinesNum ber * sizeof(IndexAdd ress)); if(AddStruct ==NULL) { printf("malloc error!\n"); return -1; }
// Prepare for sorting for(i=0; i<LinesNumber; i++) { AddStruct[i].FlashAddress=A ddress(i); AddStruct[i].index=i; } PrintAddIndex() ;
QuickSort(AddSt ruct,0,LinesNum ber); PrintAddIndex() ;
for(i=0; i<LinesNumber; i++) free(FileBuff[i]); <====== IN THIS POINT THE PROGRAM WAS THROWN. free(FileBuff);
/* Close fp */ if( fclose( fp ) ) printf( "The file %s was not closed\n",FileN ame );
return 0; }
1. I allocated an array of pointer 5. The problem is in the free() function. When I tried to free in a loop the allocated lines, the Visual C throw me with an exception.
Passing the base address of the pointer array should
free the entire memory you allocated in step 1 (I assume you
allocated one big chunk). As somebody posted before, you might
be trying to free the same memory twice.
Rgds.
Amogh
Kelsey Bjarnason wrote: [snips]
On Thu, 27 Apr 2006 03:15:30 -0700, a.*****@solidgr oup.com wrote:
#define byte unsigned char #define word unsigned short
Some reason for not using typedefs?
FILE *fp; char **FileBuff; IndexAddres s *AddStruct; word LinesNumber=0;
int main(int argc, char* argv[]) { char FileName[]={"c:\\ariel\\f lash196\\modbus .hex"};
Ick. Lose the braces.
char line[MAX_LINE]; long BufSize=0; word i,LineLen=0;
// Open for read (will fail if file "FileName" does not exist) if( (fp = fopen( FileName, "r" )) == NULL ) printf( "The file %s was not opened\n",FileN ame ); else printf( "The file '%s was opened\n",FileN ame );
If it doesn't open, wouldn't it be more graceful to handle that explicitly, say by exiting, or whatever?
// Finds Number of lines in the Hex File while (!feof(fp)) { fgets(line,MAX_ LINE,fp); LinesNumber++; }
Ugly, as it gets the eof test bass-ackwards. Basically, feof is only going to be true _after_ fgets fails, reading past the last line.
printf("\nLines Number=%d\n",Li nesNumber);
// Allocate an array of pointers to number of lines if((FileBuff = (char **)malloc(Lines Number * sizeof(char *)))==NULL) {
Repeat after me: "We do *not* cast malloc." Repeat five or six hundred times. If your compiler is complaining, then a) You're actually using C++, b) You forget a header you need, or c) you're doing something wrong.
printf("malloc error!\n"); return -1;
No such critter as -1. It's 0, EXIT_SUCCESS or EXIT_FAILURE.
// Read line by line from file, allocate a memory to it and copy line to allocation for(i=0; i<LinesNumber; i++) { fgets(line,MAX_ LINE,fp); if((FileBuff[i] = (char *)malloc(strlen (line) * sizeof(char)) )==NULL)
Why are you using sizeof(char)? If you had to multiply 7*3, would you write it as (7*1) * (3*1)? No? So why are you doing completely pointless multiplication by 1? Hint: sizeof(char) is 1. Period. Hence it's completely pointless in virtually every case you'll ever see it used.
That said, you're allocating one too few characters. For example, if your line in the file is ABC\n, your "line" variable will contain "ABC\n\0". That's 5 chars - but strlen only returns 4; it doesn't include the \0 at the end. So you're short one byte.
strcpy(FileBuff[i],line);
And, of course, this right here may well puke and die as you try to merrily write past the end of the allocated region.
for(i=0; i<LinesNumber; i++) free(FileBuff[i]); <====== IN THIS POINT THE PROGRAM WAS THROWN.
At a guess, since none of your strings are actually strings - lacking the \0 - I'd suspect you're trashing the data that malloc/free use to track what's been allocated.
It's also entirely possible that your sort routine is mucking things up; if it's doing string-based comparisons on non-strings, bad things will happen there, too.
Repeat after me: "We do *not* cast malloc." Repeat five or six hundred times. If your compiler is complaining, then a) You're actually using C++, b) You forget a header you need, or c) you're doing something >wrong.
Why shouldnt one cast malloc ? I use gcc 3.2, and it does crib if I dont
cast malloc. I might be missing your point somehow. Please enlighten.
Rgds.
Amogh
Amogh opined: Kelsey Bjarnason wrote: [snips]
>Repeat after me: "We do *not* cast malloc." Repeat five or six >hundred >times. If your compiler is complaining, then a) You're actually >using C++, b) You forget a header you need, or c) you're doing >something >wrong. Why shouldnt one cast malloc ? I use gcc 3.2, and it does crib if I dont cast malloc.
That'd be because you forgot to include <stdlib.h>.
I might be missing your point somehow. Please enlighten.
The point is to crib if you forget to include <stdlib.h>
All other points made above apply as well.
--
"It's God. No, not Richard Stallman, or Linus Torvalds, but God."
(By Matt Welsh)
<http://clc-wiki.net/wiki/Introduction_to _comp.lang.c>
Vladimir Oka opined: Amogh opined:
Kelsey Bjarnason wrote: [snips]
>Repeat after me: "We do *not* cast malloc." Repeat five or six >hundred >times. If your compiler is complaining, then a) You're actually >using C++, b) You forget a header you need, or c) you're doing >something >wrong.
Why shouldnt one cast malloc ? I use gcc 3.2, and it does crib if I dont cast malloc.
That'd be because you forgot to include <stdlib.h>.
I might be missing your point somehow. Please enlighten.
The point is to crib if you forget to include <stdlib.h> All other points made above apply as well.
To expand a bit:
If you don't include <stdlib.h> the compiler does not see a prototype
for `malloc()` and is forced to assume it returns an `int`. If you
don't cast, it will then complain about assigning an `int` to a
pointer. If you, however, do cast, compiler will try to interpret the
pointer returned by `malloc()` as an `int` and then convert that `int`
back to your pointer type. Therein lies the monster of Undefined
Behaviour, and weird things may happen.
--
"... freedom ... is a worship word..."
"It is our worship word too."
-- Cloud William and Kirk, "The Omega Glory", stardate unknown
<http://clc-wiki.net/wiki/Introduction_to _comp.lang.c> This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Charlie |
last post by:
Hello,
I have data in an Access table that I would like to export to multiple
HTML tables. I would like to split the data in the Access table
(about 92,000 records) into multiple HTML tables/files to reduce
download time and bandwidth usage on my web server. That way, the
user can select a particular page to download instead of downloading a
page with all of the records.
I would like to set a limit of only 500 records per file.
|
by: Aaron Walker |
last post by:
I apologize if this is a stupid question. I was just curious... is
there any reason why free() doesn't set the pointer (that was passed to
it) to NULL after giving the memory back to the heap? I decided to
write a wrapper for free() to do just that, and I wondered why free()
itself didn't do it.
Aaron
--
/usr/bin/fortune says:
How can you work when the system's so crowded?
|
by: weaselboy1976 |
last post by:
Hello
Does anyone know of a good website that actually describes and
demonstrates WHY freeing a pointer more than once is a problem. I'm
specifically interested in what the ill effects are.
Also, if you know of any really good books that describe everything
about memory in a c program ...
Thanks in advance!
|
by: boris |
last post by:
Hi!
I'm seeking some answers about what seems to be a memory leak.
I have a loop that looks much like this:
double *largeArray = (double*) calloc();
for (...) {
printf("iteration #...\n");
for (...) {
double *foo = (double*) calloc();
|
by: Walter Roberson |
last post by:
If realloc() finds it necessary to move the memory block, then
does it free() the previously allocated block?
The C89 standard has some reference to undefined behaviour if one
realloc()'s memory that was freed by realloc(), but the only way
explicitly mentioned in the C89 standard to free memory via realloc()
is to realloc() it down to 0 bytes.
I had always assumed it would automatically free the previous memory,
but is the behaviour...
| |
by: Reddy |
last post by:
Hello,
Can someone clarify this?
char *p = (char *) malloc (100*sizeof(char));
p=p+50;
free(p);
Does free clear all the 100 bytes of memory or only 50 as it is
pointing to 51st byte of memory now?
|
by: zfareed |
last post by:
Similar problem to the previous post. I have created a project with
about 7 files including 3 header files and 3 implementation files. I
am getting a multiple definition error when compiling for one specific
file of class. I have checked that if there is more than one
allocation of storage for identifiers, this error arises. But I don't
see where the problem lies. Any suggestions?
<code>
//ItemType.h
#ifndef ItemType_hpp // I was...
|
by: siddhu |
last post by:
Dear experts,
If I do free(p); memory pointed by p is freed and is available for
further allocations in the process.
But how does it decide about how much memory (size) has to to be freed
and make it available for further allocations?
Regards,
Siddharth
|
by: gianx80 |
last post by:
Hi,
I'm studying the basis of C, C++ and Assembly languages at my university (I have two exams about these subjects,
for now) ... and I have a problem ^^.
I wrote a program in C (not so optimized, this isn't our present goal for my professors) that recieves in input an
integer (matrix size) and a double pointer to a square matrix and print on screen the co-ordinate of each square
sub-matrix from size 2 to n - 1 size (where n is the...
|
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...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
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...
|
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...
|
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...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
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...
| |